Module: Low::Templates::Renderer::ClassMethods
- Defined in:
- lib/templates/renderer.rb
Instance Method Summary collapse
- #load_template(template:, params:, engine:, namespace:) ⇒ Object
-
#render(event:) ⇒ Object
TODO: Handle situation where node is tested in a unit test and args come in here; expose them to the template.
- #render_template(event:) ⇒ Object
- #template ⇒ Object
Instance Method Details
#load_template(template:, params:, engine:, namespace:) ⇒ Object
34 35 36 |
# File 'lib/templates/renderer.rb', line 34 def load_template(template:, params:, engine:, namespace:) @template = Template.new(template:, params:, engine:, namespace:) end |
#render(event:) ⇒ Object
TODO: Handle situation where node is tested in a unit test and args come in here; expose them to the template.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/templates/renderer.rb', line 39 def render(event:) node = self.new(event:) # RBX/Antlers is rendered via template while valid Ruby is rendered as written. body = @template ? node.render_template(event:) : node.render(event:) # GOAL: Make return value configurable; ResponseEvent, Response, or body. response = Low::Factories::ResponseFactory.html(body:) Low::Events::ResponseEvent.new(response:) end |
#render_template(event:) ⇒ Object
50 51 52 |
# File 'lib/templates/renderer.rb', line 50 def render_template(event:) self.new(event:).render_template(event:) end |
#template ⇒ Object
30 31 32 |
# File 'lib/templates/renderer.rb', line 30 def template @template end |