Skip to content

Commit

Permalink
Remove virtual_path_of_template. (#12)
Browse files Browse the repository at this point in the history
This method was originally created to more easily tie a page json with a
page component. It was to be used as the componentIdentifier.

A better and more maintainable approach would be to use a combination of
`controller_path` and `action` for the `componentIdentifier`. This
removes the hacky-ness of dynamically defining a method, while giving
flexibility as two controller actions can render the same template while
having a different componentIdentifier.
  • Loading branch information
jho406 committed Dec 6, 2023
1 parent 112b4d8 commit 55ace47
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions lib/props_template/layout_patch.rb
Expand Up @@ -10,18 +10,9 @@ def render_template(view, template, layout_name, locals)
end

def render_props_template(view, template, path, locals)
view.instance_eval <<~RUBY, __FILE__, __LINE__ + 1
def virtual_path_of_template;"#{template.virtual_path}";end
RUBY

# Deprecated: Usage of virtual_path_of_template in local_assigns will
# be removed for a method definition above
layout_locals = locals.dup
layout_locals[:virtual_path_of_template] = template.virtual_path

layout = resolve_layout(path, layout_locals.keys, [formats.first])
layout = resolve_layout(path, locals.keys, [formats.first])
body = if layout
layout.render(view, layout_locals) do |json|
layout.render(view, locals) do |json|
template.render(view, locals)
end
else
Expand Down

0 comments on commit 55ace47

Please sign in to comment.