diff options
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/digestor.rb | 7 | ||||
-rw-r--r-- | actionview/lib/action_view/lookup_context.rb | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index dad3cea73a..abbfdc786e 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -122,11 +122,8 @@ module ActionView def template @template ||= begin - finder.formats = [format] - finder.variants = [variant] - - finder.disable_cache do - finder.find(logical_name, [], partial?) + finder.with_formats_and_variants([format], [variant]) do + finder.disable_cache { finder.find(logical_name, [], partial?) } end end end diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index 76c9890776..d7f116c10c 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -246,5 +246,13 @@ module ActionView end end end + + def with_formats_and_variants(new_formats, new_variants) + old_formats, old_variants = formats, variants + self.formats, self.variants = new_formats, new_variants + yield + ensure + self.formats, self.variants = old_formats, old_variants + end end end |