render(:action) and render() are the only two render calls to use a layout 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
This commit is contained in:
Jamis Buck
2005-06-01 13:39:58 +00:00
parent 46e68538c0
commit e4c047e489
4 changed files with 10 additions and 11 deletions

View File

@@ -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

View File

@@ -490,7 +490,7 @@ module ActionController #:nodoc:
render(options.merge({ :text => "" }))
else
render(options.merge({ :template => default_template_name }))
render(options.merge({ :action => action_name }))
end
end

View File

@@ -220,12 +220,10 @@ module ActionController #:nodoc:
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 @@ module ActionController #:nodoc:
case options[:layout]
when FalseClass
nil
when NilClass
when NilClass, TrueClass
active_layout if action_has_layout?
else
active_layout(options[:layout])

View File

@@ -78,7 +78,7 @@ class NewRenderTestController < ActionController::Base
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 @@ class NewRenderTestController < ActionController::Base
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 @@ class NewRenderTest < Test::Unit::TestCase
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