Permalink
Browse files

render(:action) and render() are the only two render calls to use a l…

…ayout by default. All others default to :layout => false. Also, allow :layout => true to be a synonym for :layout => nil.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1378 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 46e6853 commit e4c047e4891c446024e35548e872704d132ad2f7 @jamis jamis committed Jun 1, 2005
@@ -1,10 +1,10 @@
*SVN*
-* render(:inline) always defaults to :layout => false.
+* render(:layout => true) is a synonym for render(:layout => nil)
* Make sure the benchmarking render method always returns the output of the render.
-* render(:text), render(:partial), and render(:nothing) always default to :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action.
+* render(:action) and render() are the only two calls that default to using a layout. All other render calls assume :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action.
* verify with :redirect_to won't redirect if a redirect or render has already been performed #1350
@@ -490,7 +490,7 @@ def render(options = {}, deprecated_status = nil)
render(options.merge({ :text => "" }))
else
- render(options.merge({ :template => default_template_name }))
+ render(options.merge({ :action => action_name }))
end
end
@@ -220,12 +220,10 @@ def render_with_a_layout(options = {}, deprecated_status = nil, deprecated_layou
private
def render_with_a_layout_options(options)
return options unless options.is_a?(Hash)
- case
- when options[:text], options[:partial], options[:nothing], options[:inline]
- # by default, :text, :partial, :inline, and :nothing never use a layout
- { :layout => false }.merge(options)
- else
+ if options.values_at(:text, :file, :template, :inline, :partial, :nothing).compact.empty?
options
+ else
+ { :layout => false }.merge(options)
end
end
@@ -236,7 +234,7 @@ def pick_layout(options = {}, deprecated_layout = nil)
case options[:layout]
when FalseClass
nil
- when NilClass
+ when NilClass, TrueClass
active_layout if action_has_layout?
else
active_layout(options[:layout])
@@ -78,7 +78,7 @@ def partial_only
end
def partial_only_with_layout
- render :partial => "partial_only", :layout => nil
+ render :partial => "partial_only", :layout => true
end
def hello_in_a_string
@@ -99,7 +99,7 @@ def rescue_action(e) raise end
private
def determine_layout
case action_name
- when "layout_test", "rendering_without_layout",
+ when "hello_world", "layout_test", "rendering_without_layout",
"rendering_nothing_on_layout", "render_text_hello_world",
"partial_only", "partial_only_with_layout",
"accessing_params_in_template",
@@ -132,6 +132,7 @@ def test_simple_show
get :hello_world
assert_response :success
assert_template "test/hello_world"
+ assert_equal "<html>Hello world!</html>", @response.body
end
def test_do_with_render

0 comments on commit e4c047e

Please sign in to comment.