提交 2de36463 编写于 作者: J Jeff Kreeftmeijer 提交者: Jeremy Kemper

partial counters with :as [#2804 state:resolved]

Signed-off-by: NJeremy Kemper <jeremy@bitsweat.net>
上级 8e7a64d0
......@@ -218,6 +218,7 @@ def render_partial_collection(options = {}) #:nodoc:
ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path)
template = _pick_partial_template(_partial_path)
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)
index += 1
result
......
......@@ -652,6 +652,10 @@ def partial_collection_with_counter
render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ]
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
render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" }
end
......@@ -1470,6 +1474,11 @@ def test_partial_collection_with_counter
assert_equal "david0mary1", @response.body
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
get :partial_collection_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body
......
<%= client.name %><%= client_counter %>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册