From 1581cab9ff26731ed03a17f7ddec3c85d536988a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 15 Feb 2019 17:10:28 -0800 Subject: Pass the template format to the digestor This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack. --- actionview/lib/action_view/base.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionview/lib/action_view/base.rb') diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb index 712e5d251e..56e0e3275c 100644 --- a/actionview/lib/action_view/base.rb +++ b/actionview/lib/action_view/base.rb @@ -257,6 +257,7 @@ module ActionView #:nodoc: end @view_renderer = ActionView::Renderer.new @lookup_context + @current_template = nil @cache_hit = {} assign(assigns) @@ -264,12 +265,13 @@ module ActionView #:nodoc: _prepare_context end - def run(method, locals, buffer, &block) - _old_output_buffer, _old_virtual_path = @output_buffer, @virtual_path + def run(method, template, locals, buffer, &block) + _old_output_buffer, _old_virtual_path, _old_template = @output_buffer, @virtual_path, @current_template + @current_template = template @output_buffer = buffer send(method, locals, buffer, &block) ensure - @output_buffer, @virtual_path = _old_output_buffer, _old_virtual_path + @output_buffer, @virtual_path, @current_template = _old_output_buffer, _old_virtual_path, _old_template end def compiled_method_container -- cgit v1.2.3