diff --git a/lib/props_template/layout_patch.rb b/lib/props_template/layout_patch.rb index 9153100..b84ca0c 100644 --- a/lib/props_template/layout_patch.rb +++ b/lib/props_template/layout_patch.rb @@ -1,6 +1,12 @@ module Props module LayoutPatch def render_template(view, template, layout_name, locals) + unless view.respond_to? :active_template_virtual_path + view.instance_eval <<~RUBY, __FILE__, __LINE__ + 1 + def active_template_virtual_path; "#{template.virtual_path}";end + RUBY + end + if template.respond_to?(:handler) && template.handler == Props::Handler && layout_name prepend_formats(template.format) render_props_template(view, template, layout_name, locals) @@ -11,6 +17,7 @@ def render_template(view, template, layout_name, locals) def render_props_template(view, template, path, locals) layout = resolve_layout(path, locals.keys, [formats.first]) + body = if layout layout.render(view, locals) do |json| template.render(view, locals)