Class: ActionView::Template::Handlers::Liquid
- Inherits:
-
Object
- Object
- ActionView::Template::Handlers::Liquid
- Defined in:
- lib/nisetegami/liquid_template_handler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #compilable? ⇒ Boolean
-
#initialize(view) ⇒ Liquid
constructor
A new instance of Liquid.
- #render(template, local_assigns = {}) ⇒ Object
Constructor Details
#initialize(view) ⇒ Liquid
Returns a new instance of Liquid.
7 8 9 |
# File 'lib/nisetegami/liquid_template_handler.rb', line 7 def initialize(view) @view = view end |
Class Method Details
.call(template) ⇒ Object
3 4 5 |
# File 'lib/nisetegami/liquid_template_handler.rb', line 3 def self.call(template) "ActionView::Template::Handlers::Liquid.new(self).render(#{template.source.inspect}, local_assigns)" end |
Instance Method Details
#compilable? ⇒ Boolean
29 30 31 |
# File 'lib/nisetegami/liquid_template_handler.rb', line 29 def compilable? false end |
#render(template, local_assigns = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nisetegami/liquid_template_handler.rb', line 11 def render(template, local_assigns = {}) assigns = @view.assigns assigns["content_for_layout"] = @view.content_for(:layout) if @view.content_for?(:layout) assigns.merge!(local_assigns.stringify_keys) controller = @view.controller filters = if controller.respond_to?(:liquid_filters, true) controller.send(:liquid_filters) elsif controller.respond_to?(:master_helper_module) [controller.master_helper_module] else [controller._helpers] end liquid = Liquid::Template.parse(template) liquid.render(assigns, filters: filters, registers: { action_view: @view, controller: @view.controller }) end |