From 01af965a3e68f719fe9cfdce36a82ad8901fe7a7 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Thu, 1 Sep 2005 21:43:38 +0000 Subject: Make rendering an empty partial collection behave like :nothing => true #2080 [Sam Stephenson] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2093 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_view/partials.rb | 2 +- actionpack/test/controller/new_render_test.rb | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9ff0ca0cb2..82f72df2bf 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Make rendering an empty partial collection behave like :nothing => true #2080 [Sam Stephenson] + * Add option to specify the singular name used by pagination. * Use string key to obtain action value. Allows indifferent hashes to be disabled. diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb index 06dead1b23..e1dcd4ee9d 100644 --- a/actionpack/lib/action_view/partials.rb +++ b/actionpack/lib/action_view/partials.rb @@ -67,7 +67,7 @@ module ActionView collection_of_partials.push(render_partial(partial_name, element, local_assigns)) end - return nil if collection_of_partials.empty? + return " " if collection_of_partials.empty? if partial_spacer_template spacer_path, spacer_name = partial_pieces(partial_spacer_template) diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index a29a6b9cd2..7cb3643db5 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -98,6 +98,10 @@ class NewRenderTestController < ActionController::Base render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } end + def empty_partial_collection + render :partial => "customer", :collection => [] + end + def hello_in_a_string @customers = [ Customer.new("david"), Customer.new("mary") ] render :text => "How's there? #{render_to_string("test/list")}" @@ -358,6 +362,11 @@ class NewRenderTest < Test::Unit::TestCase assert_equal "Bonjour: davidBonjour: mary", @response.body end + def test_empty_partial_collection + get :empty_partial_collection + assert_equal " ", @response.body + end + def test_render_text_with_assigns get :render_text_with_assigns assert_equal "world", assigns["hello"] -- cgit v1.2.3