Permalink
Browse files

Adds line to change log and update documentation.

  • Loading branch information...
1 parent e4e1388 commit 6e0a763d0047dcaae26fb691757c3407a20e4a84 @Serabe Serabe committed Mar 6, 2012
Showing with 39 additions and 0 deletions.
  1. +2 −0 actionpack/CHANGELOG.md
  2. +37 −0 actionpack/lib/action_view/renderer/partial_renderer.rb
View
2 actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Adds support for layouts when rendering a partial with a given collection. *serabe*
+
* Allows the route helper `root` to take a string argument. For example, `root 'pages#main'`. *bcardarella*
* Forms of persisted records use always PATCH (via the `_method` hack). *fxn*
View
37 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 &>

0 comments on commit 6e0a763

Please sign in to comment.