Class: Lesmok::Tags::ErbInclude::ErbRenderer
- Inherits:
-
Object
- Object
- Lesmok::Tags::ErbInclude::ErbRenderer
- Defined in:
- lib/lesmok/tags/erb_include.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #call(args = {}) ⇒ Object
- #ctrl ⇒ Object
- #extract_vars ⇒ Object
-
#initialize(liquid_context, template_name) ⇒ ErbRenderer
constructor
A new instance of ErbRenderer.
- #view ⇒ Object
Constructor Details
#initialize(liquid_context, template_name) ⇒ ErbRenderer
Returns a new instance of ErbRenderer.
11 12 13 14 |
# File 'lib/lesmok/tags/erb_include.rb', line 11 def initialize(liquid_context, template_name) @context = liquid_context @template_name = template_name end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/lesmok/tags/erb_include.rb', line 10 def context @context end |
Instance Method Details
#call(args = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lesmok/tags/erb_include.rb', line 31 def call(args = {}) template_name = context[@template_name] default_args = { partial: template_name, template: template_name, registers: context.registers, locals: context.scopes.last.with_indifferent_access, # TODO: Make this work? liquid_context: context, } render_args = default_args.merge(args) ctrl.send(:render, render_args) end |
#ctrl ⇒ Object
23 24 25 |
# File 'lib/lesmok/tags/erb_include.rb', line 23 def ctrl context.registers[:controller] end |
#extract_vars ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/lesmok/tags/erb_include.rb', line 15 def extract_vars # Not needed if we use action_view directly? ctrl.instance_variables.each do |key| val = ctrl.instance_variable_get(key) self.instance_variable_set(key, val) end if ctrl end |
#view ⇒ Object
27 28 29 |
# File 'lib/lesmok/tags/erb_include.rb', line 27 def view context.registers[:action_view] end |