Class: Lutaml::Model::Schema::Renderer
- Inherits:
-
Object
- Object
- Lutaml::Model::Schema::Renderer
- Defined in:
- lib/lutaml/model/schema/renderer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(template_path) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(context = {}) ⇒ Object
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 |