Class: Lutaml::Model::Schema::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/model/schema/renderer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_path) ⇒ Renderer

Returns a new instance of Renderer.



24
25
26
# File 'lib/lutaml/model/schema/renderer.rb', line 24

def initialize(template_path)
  @template = File.read(template_path)
end

Class Method Details

.render(template_path, context = {}) ⇒ Object



20
21
22
# File 'lib/lutaml/model/schema/renderer.rb', line 20

def self.render(template_path, context = {})
  new(template_path).render(context)
end

Instance Method Details

#render(context = {}) ⇒ Object



28
29
30
31
32
# File 'lib/lutaml/model/schema/renderer.rb', line 28

def render(context = {})
  context = Context.new(context[:schema])

  ERB.new(@template, trim_mode: "-").result(context.instance_eval { binding })
end