Skip to content

Commit

Permalink
partial counters with :as [#2804 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
Jeff Kreeftmeijer authored and jeremy committed May 15, 2010
1 parent 8e7a64d commit 2de3646
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_view/partials.rb
Expand Up @@ -218,6 +218,7 @@ def render_partial_collection(options = {}) #:nodoc:
ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path) ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path)
template = _pick_partial_template(_partial_path) template = _pick_partial_template(_partial_path)
local_assigns[template.counter_name] = index local_assigns[template.counter_name] = index
local_assigns["#{as.to_s}_counter".to_sym] = local_assigns[template.counter_name]
result = template.render_partial(self, object, local_assigns.dup, as) result = template.render_partial(self, object, local_assigns.dup, as)
index += 1 index += 1
result result
Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -652,6 +652,10 @@ def partial_collection_with_counter
render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ] render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ]
end end


def partial_collection_with_as_and_counter
render :partial => "customer_counter_with_as", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :client
end

def partial_collection_with_locals def partial_collection_with_locals
render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" } render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" }
end end
Expand Down Expand Up @@ -1470,6 +1474,11 @@ def test_partial_collection_with_counter
assert_equal "david0mary1", @response.body assert_equal "david0mary1", @response.body
end end


def test_partial_collection_with_as_and_counter
get :partial_collection_with_as_and_counter
assert_equal "david0mary1", @response.body
end

def test_partial_collection_with_locals def test_partial_collection_with_locals
get :partial_collection_with_locals get :partial_collection_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body assert_equal "Bonjour: davidBonjour: mary", @response.body
Expand Down
@@ -0,0 +1 @@
<%= client.name %><%= client_counter %>

0 comments on commit 2de3646

Please sign in to comment.