Skip to content

Commit

Permalink
Use rails resolve_layout
Browse files Browse the repository at this point in the history
It seems like I didn't need to provide an alternative to resolve_layout after
all! This is great because it makes the layout patch so much simpler.
  • Loading branch information
jho406 committed Jun 28, 2023
1 parent f3a3ffb commit 9ac48df
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions lib/props_template/layout_patch.rb
Expand Up @@ -13,7 +13,7 @@ def render_props_template(view, template, path, locals)
layout_locals = locals.dup
layout_locals[:virtual_path_of_template] = template.virtual_path

layout = resolve_props_layout(path, layout_locals.keys, [formats.first])
layout = resolve_layout(path, layout_locals.keys, [formats.first])
body = if layout
layout.render(view, layout_locals) do |json|
template.render(view, locals)
Expand All @@ -24,27 +24,6 @@ def render_props_template(view, template, path, locals)

build_rendered_template(body, template)
end

def resolve_props_layout(layout, keys, formats)
details = @details.dup
details[:formats] = formats

case layout
when String
begin
if layout.start_with?("/")
ActiveSupport::Deprecation.warn "Rendering layouts from an absolute path is deprecated."
@lookup_context.with_fallbacks.find_template(layout, nil, false, [], details)
else
@lookup_context.find_template(layout, nil, false, [], details)
end
end
when Proc
resolve_props_layout(layout.call(@lookup_context, formats), keys, formats)
else
layout
end
end
end
end

Expand Down

0 comments on commit 9ac48df

Please sign in to comment.