Created
January 23, 2013 12:54
-
-
Save greendog/4605222 to your computer and use it in GitHub Desktop.
Revisions
-
greendog created this gist
Jan 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ class ActionView::Template::Handlers::Liquid def self.call(template) "ActionView::Template::Handlers::Liquid.new(self).render(#{template.source.inspect}, local_assigns)" end def initialize(view) @view = view end def render(template, local_assigns = {}) @view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8' assigns = @view.assigns if @view.content_for?(:layout) assigns["content_for_layout"] = @view.content_for(:layout) end 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 def compilable? false end end