diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-11 17:24:24 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-11 17:55:59 -0800 |
commit | 2b6d2d20374130da469ece24842ce3b681d3b788 (patch) | |
tree | affbde8be64402578fbef1f5a15950e418e7b4fc /actionview/lib/action_view/rendering.rb | |
parent | 9439a18bf76b3b7c759340abf0d7a5fb17fc82f7 (diff) | |
download | rails-2b6d2d20374130da469ece24842ce3b681d3b788.tar.gz rails-2b6d2d20374130da469ece24842ce3b681d3b788.tar.bz2 rails-2b6d2d20374130da469ece24842ce3b681d3b788.zip |
Turn lookup context in to a stack, push and pop if formats change
This commit keeps a stack of lookup contexts on the ActionView::Base
instance. If a format is passed to render, we instantiate a new lookup
context and push it on the stack, that way any child calls to "render"
will use the same format information as the parent. This also isolates
"sibling" calls to render (multiple calls to render in the same
template).
Fixes #35222 #34138
Diffstat (limited to 'actionview/lib/action_view/rendering.rb')
-rw-r--r-- | actionview/lib/action_view/rendering.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionview/lib/action_view/rendering.rb b/actionview/lib/action_view/rendering.rb index da92ce1f5e..b798e80b04 100644 --- a/actionview/lib/action_view/rendering.rb +++ b/actionview/lib/action_view/rendering.rb @@ -82,7 +82,7 @@ module ActionView # # Override this method in a module to change the default behavior. def view_context - view_context_class.new(view_renderer, view_assigns, self) + view_context_class.new(lookup_context, view_assigns, self) end # Returns an object that is able to render templates. @@ -112,7 +112,7 @@ module ActionView lookup_context.rendered_format = nil if options[:formats] lookup_context.variants = variant if variant - view_renderer.render(context, options) + context.view_renderer.render(context, options) end # Assign the rendered format to look up context. |