Class: Heartml::TemplateRenderer
- Inherits:
-
ServerComponent
- Object
- ServerComponent
- Heartml::TemplateRenderer
- Defined in:
- lib/heartml/template_renderer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(body:, context:) ⇒ TemplateRenderer
constructor
rubocop:disable Lint/MissingSuper.
-
#method_missing(key) ⇒ Object
TODO: delegate instead?.
- #respond_to_missing?(key) ⇒ Boolean
Methods inherited from ServerComponent
Constructor Details
#initialize(body:, context:) ⇒ TemplateRenderer
rubocop:disable Lint/MissingSuper
22 23 24 25 26 |
# File 'lib/heartml/template_renderer.rb', line 22 def initialize(body:, context:) # rubocop:disable Lint/MissingSuper @doc_html = body.is_a?(String) ? body : body.to_html @body = body.is_a?(String) ? Nokolexbor::DocumentFragment.parse(body) : body @context = context end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key) ⇒ Object
TODO: delegate instead?
38 39 40 |
# File 'lib/heartml/template_renderer.rb', line 38 def method_missing(key, *, **) context.send(key, *, **) end |
Class Method Details
.heart_module ⇒ Object
18 19 20 |
# File 'lib/heartml/template_renderer.rb', line 18 def self.heart_module "eval" end |
Instance Method Details
#call ⇒ Object
28 29 30 31 |
# File 'lib/heartml/template_renderer.rb', line 28 def call Fragment.new(@body, self).process @body end |
#respond_to_missing?(key) ⇒ Boolean
33 34 35 |
# File 'lib/heartml/template_renderer.rb', line 33 def respond_to_missing?(key) context.respond_to?(key) end |