diff options
author | Aaron Patterson <tenderlove@github.com> | 2019-02-22 11:20:33 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-22 11:20:33 -0800 |
commit | 5e29ea0f2a4d483cdd09ce61c5f53b785d876af0 (patch) | |
tree | 5c32dfd44b82f6aea9476719a4262fd19fad0f63 | |
parent | a333ba3f7f24dff3c50c7cf26a2fe2caa748a851 (diff) | |
parent | 1cf3878927c086828d7a3010012334859c98d643 (diff) | |
download | rails-5e29ea0f2a4d483cdd09ce61c5f53b785d876af0.tar.gz rails-5e29ea0f2a4d483cdd09ce61c5f53b785d876af0.tar.bz2 rails-5e29ea0f2a4d483cdd09ce61c5f53b785d876af0.zip |
Merge pull request #35369 from rails/fewer-lookup-context-calls
Pass lookup context to the layout handlers
-rw-r--r-- | actionview/lib/action_view/layouts.rb | 10 | ||||
-rw-r--r-- | actionview/lib/action_view/renderer/template_renderer.rb | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index 3e6d352c15..08f66bf435 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -322,7 +322,7 @@ module ActionView end class_eval <<-RUBY, __FILE__, __LINE__ + 1 - def _layout(formats) + def _layout(lookup_context, formats) if _conditional_layout? #{layout_definition} else @@ -388,8 +388,8 @@ module ActionView case name when String then _normalize_layout(name) when Proc then name - when true then Proc.new { |formats| _default_layout(formats, true) } - when :default then Proc.new { |formats| _default_layout(formats, false) } + when true then Proc.new { |lookup_context, formats| _default_layout(lookup_context, formats, true) } + when :default then Proc.new { |lookup_context, formats| _default_layout(lookup_context, formats, false) } when false, nil then nil else raise ArgumentError, @@ -411,9 +411,9 @@ module ActionView # # ==== Returns # * <tt>template</tt> - The template object for the default layout (or +nil+) - def _default_layout(formats, require_layout = false) + def _default_layout(lookup_context, formats, require_layout = false) begin - value = _layout(formats) if action_has_layout? + value = _layout(lookup_context, formats) if action_has_layout? rescue NameError => e raise e, "Could not render layout: #{e.message}" end diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index c17d6182e8..b6861d49fe 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -88,7 +88,7 @@ module ActionView raise unless template_exists?(layout, nil, false, [], all_details) end when Proc - resolve_layout(layout.call(formats), keys, formats) + resolve_layout(layout.call(@lookup_context, formats), keys, formats) else layout end |