test/controller/render_test.rb:650: trailing whitespace. + test/controller/render_test.rb:1466: trailing whitespace. + diff --git a/lib/action_view/partials.rb b/lib/action_view/partials.rb index 9e5e0f7..d6b8600 100644 --- a/lib/action_view/partials.rb +++ b/lib/action_view/partials.rb @@ -218,6 +218,7 @@ module ActionView ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path) template = _pick_partial_template(_partial_path) local_assigns[template.counter_name] = index + local_assigns["#{as}_counter".to_sym] = index if as result = template.render_partial(self, object, local_assigns.dup, as) index += 1 result diff --git a/test/controller/render_test.rb b/test/controller/render_test.rb index a529315..fb89140 100644 --- a/test/controller/render_test.rb +++ b/test/controller/render_test.rb @@ -647,6 +647,10 @@ class TestController < ActionController::Base def partial_collection_with_counter render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ] end + + def partial_collection_with_counter_and_as + render :partial => "customer_counter_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer + end def partial_collection_with_locals render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } @@ -1459,6 +1463,11 @@ class RenderTest < ActionController::TestCase get :partial_collection_with_counter assert_equal "david0mary1", @response.body end + + def test_partial_collection_with_counter_and_as + get :partial_collection_with_counter_and_as + assert_equal "david david david 0 0mary mary mary 1 1", @response.body + end def test_partial_collection_with_locals get :partial_collection_with_locals diff --git a/test/fixtures/test/_customer_counter_with_var.erb b/test/fixtures/test/_customer_counter_with_var.erb new file mode 100644 index 0000000..8420c5f --- /dev/null +++ b/test/fixtures/test/_customer_counter_with_var.erb @@ -0,0 +1 @@ +<%= customer.name %> <%= object.name %> <%= customer_counter_with_var.name %> <%= customer_counter %> <%= customer_counter_with_var_counter %> \ No newline at end of file