diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-22 11:58:04 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2019-02-22 11:58:04 -0800 |
commit | 62cb3ee35c5c0d729c54b057c37b8f6bed4dda7f (patch) | |
tree | bf6227cab8ce3e46aad24bb383eb37044625a0b2 /actionview/lib/action_view/renderer/template_renderer.rb | |
parent | 3b6602aa7a01fb415fce07ef32458b131e5762e1 (diff) | |
download | rails-62cb3ee35c5c0d729c54b057c37b8f6bed4dda7f.tar.gz rails-62cb3ee35c5c0d729c54b057c37b8f6bed4dda7f.tar.bz2 rails-62cb3ee35c5c0d729c54b057c37b8f6bed4dda7f.zip |
Ensure that rendered templates always have a format
This removes one call to `lookup_context` and also eliminates a
conditional in `_render_template`.
Diffstat (limited to 'actionview/lib/action_view/renderer/template_renderer.rb')
-rw-r--r-- | actionview/lib/action_view/renderer/template_renderer.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index c17d6182e8..5bd14af128 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -29,7 +29,12 @@ module ActionView @lookup_context.with_fallbacks.find_file(options[:file], nil, false, keys, @details) elsif options.key?(:inline) handler = Template.handler_for_extension(options[:type] || "erb") - Template.new(options[:inline], "inline template", handler, locals: keys) + format = if handler.respond_to?(:default_format) + handler.default_format + else + @lookup_context.formats.first + end + Template.new(options[:inline], "inline template", handler, locals: keys, format: format) elsif options.key?(:template) if options[:template].respond_to?(:render) options[:template] |