diff --git a/actionpack/lib/action_view/renderer/abstract_renderer.rb b/actionpack/lib/action_view/renderer/abstract_renderer.rb index 1656cf7ec7..03feeff16c 100644 --- a/actionpack/lib/action_view/renderer/abstract_renderer.rb +++ b/actionpack/lib/action_view/renderer/abstract_renderer.rb @@ -12,7 +12,18 @@ module ActionView end protected - + + def extract_details(options) + details = {} + @lookup_context.registered_details.each do |key| + next unless value = options[key] + details[key] = Array.wrap(value) + end + details + end + + + def extract_format(value, details) if value.is_a?(String) && value.sub!(formats_regexp, "") ActiveSupport::Deprecation.warn "Passing the format in the template name is deprecated. " \ diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb index f3e7378f2b..ac91d333ba 100644 --- a/actionpack/lib/action_view/renderer/template_renderer.rb +++ b/actionpack/lib/action_view/renderer/template_renderer.rb @@ -5,7 +5,7 @@ module ActionView class TemplateRenderer < AbstractRenderer #:nodoc: def render(context, options) @view = context - @details = options.slice(:formats, :locale, :handlers) + @details = extract_details(options) extract_format(options[:file] || options[:template], @details) template = determine_template(options) freeze_formats(template.formats, true) diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 634e1cdd9f..5637f3f42e 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -36,6 +36,7 @@ module RenderTestCases def test_render_file_with_format assert_equal "

No Comment

", @view.render(:file => "comments/empty", :formats => [:html]) assert_equal "No Comment", @view.render(:file => "comments/empty", :formats => [:xml]) + assert_equal "No Comment", @view.render(:file => "comments/empty", :formats => :xml) end def test_render_template_with_format @@ -45,6 +46,7 @@ module RenderTestCases def test_render_file_with_locale assert_equal "

Kein Kommentar

", @view.render(:file => "comments/empty", :locale => [:de]) + assert_equal "

Kein Kommentar

", @view.render(:file => "comments/empty", :locale => :de) end def test_render_template_with_locale @@ -53,6 +55,7 @@ module RenderTestCases def test_render_file_with_handlers assert_equal "

No Comment

\n", @view.render(:file => "comments/empty", :handlers => [:builder]) + assert_equal "

No Comment

\n", @view.render(:file => "comments/empty", :handlers => :builder) end def test_render_template_with_handlers