Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow both sym and array for details options in #render. using LC#reg…

…istered_details to extract options.
  • Loading branch information...
commit 2e3eb2560b7686a633d6de35c4cd9131504aee38 1 parent f8e6664
@apotonick apotonick authored josevalim committed
View
13 actionpack/lib/action_view/renderer/abstract_renderer.rb
@@ -12,7 +12,18 @@ def render
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. " \
View
2  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)
View
3  actionpack/test/template/render_test.rb
@@ -36,6 +36,7 @@ def test_render_file_without_specific_extension
def test_render_file_with_format
assert_equal "<h1>No Comment</h1>", @view.render(:file => "comments/empty", :formats => [:html])
assert_equal "<error>No Comment</error>", @view.render(:file => "comments/empty", :formats => [:xml])
+ assert_equal "<error>No Comment</error>", @view.render(:file => "comments/empty", :formats => :xml)
end
def test_render_template_with_format
@@ -45,6 +46,7 @@ def test_render_template_with_format
def test_render_file_with_locale
assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => [:de])
+ assert_equal "<h1>Kein Kommentar</h1>", @view.render(:file => "comments/empty", :locale => :de)
end
def test_render_template_with_locale
@@ -53,6 +55,7 @@ def test_render_template_with_locale
def test_render_file_with_handlers
assert_equal "<h1>No Comment</h1>\n", @view.render(:file => "comments/empty", :handlers => [:builder])
+ assert_equal "<h1>No Comment</h1>\n", @view.render(:file => "comments/empty", :handlers => :builder)
end
def test_render_template_with_handlers
Please sign in to comment.
Something went wrong with that request. Please try again.