25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/lesmok/railing/action_view_handler.rb', line 25
def render(template, local_assigns = {})
@view.controller.["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)
render_assigns = assigns.with_indifferent_access
render_opts = {:filters => filters, :registers => {:action_view => @view, :controller => @view.controller}}
if self.class.lesmok_options[:rethrow_errors]
text = liquid.render!(render_assigns, render_opts)
else
text = liquid.render(render_assigns, render_opts)
end
if ::Lesmok.config.debugging?
log_any_liquid_errors(liquid.errors)
log_any_liquid_errors(liquid.warnings, 'warning')
end
text.html_safe
end
|