aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/renderer/partial_renderer.rb
diff options
context:
space:
mode:
authorSergio Arbeo <serabe@gmail.com>2012-03-07 00:06:42 +0100
committerSergio Arbeo <serabe@gmail.com>2012-03-07 00:06:42 +0100
commit6e0a763d0047dcaae26fb691757c3407a20e4a84 (patch)
tree5d4894bd4aea2a2b0b3663e15d7a082d58e2ca88 /actionpack/lib/action_view/renderer/partial_renderer.rb
parente4e1388318cd281bf27114b608487330ae1a58df (diff)
downloadrails-6e0a763d0047dcaae26fb691757c3407a20e4a84.tar.gz
rails-6e0a763d0047dcaae26fb691757c3407a20e4a84.tar.bz2
rails-6e0a763d0047dcaae26fb691757c3407a20e4a84.zip
Adds line to change log and update documentation.
Diffstat (limited to 'actionpack/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index ac4c8db50e..245a19deec 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -158,6 +158,43 @@ module ActionView
# Name: <%= user.name %>
# </div>
#
+ # If a collection is given, the layout will be rendered once for each item in the collection. Just think
+ # these two snippets have the same output:
+ #
+ # <%# app/views/users/_user.html.erb %>
+ # Name: <%= user.name %>
+ #
+ # <%# app/views/users/index.html.erb %>
+ # <%# This does not use layouts %>
+ # <ul>
+ # <% users.each do |user| -%>
+ # <li>
+ # <%= render :partial => "user", :locals => { :user => user } %>
+ # </li>
+ # <% end -%>
+ # </ul>
+ #
+ # <%# app/views/users/_li_layout.html.erb %>
+ # <li>
+ # <%= yield %>
+ # </li>
+ #
+ # <%# app/views/users/index.html.erb %>
+ # <ul>
+ # <%= render :partial => "user", :layout => "li_layout", :collection => users %>
+ # </ul>
+ #
+ # Given two users whose names are Alice and Bob, these snippets return:
+ #
+ # <ul>
+ # <li>
+ # Name: Alice
+ # </li>
+ # <li>
+ # Name: Bob
+ # </li>
+ # </ul>
+ #
# You can also apply a layout to a block within any template:
#
# <%# app/views/users/_chief.html.erb &>