aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-09-13 23:10:43 +0200
committerXavier Noria <fxn@hashref.com>2010-09-13 23:10:43 +0200
commit0522b26cdf15ba1b5c89fc64f9069e1a13cafcff (patch)
tree6d720bbdf00273eed0a5af3a4f01472ea4fcaf6c /actionpack/lib/action_view
parent2eb5476d2218c4d213aecab112788448bdcbcb82 (diff)
downloadrails-0522b26cdf15ba1b5c89fc64f9069e1a13cafcff.tar.gz
rails-0522b26cdf15ba1b5c89fc64f9069e1a13cafcff.tar.bz2
rails-0522b26cdf15ba1b5c89fc64f9069e1a13cafcff.zip
reviews 02656ac
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/render/partials.rb35
1 files changed, 17 insertions, 18 deletions
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb
index bfec3d36b0..cc9b444837 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/render/partials.rb
@@ -28,34 +28,33 @@ module ActionView
#
# == The :as and :object options
#
- # By default PartialRenderer uses the template name for the local name of the object passed into the template.
- # These examples are effectively the same:
- #
- # <%= render :partial => "contract", :locals => { :contract => @contract } %>
- #
+ # By default <tt>ActionView::Partials::PartialRenderer</tt> has its object in a local variable with the same
+ # name as the template. So, given
+ #
# <%= render :partial => "contract" %>
#
- # By specifying the :as option we can change the way the local variable is namedin the template.
- # These examples are effectively the same:
- #
- # <%= render :partial => "contract", :as => :agreement
- #
- # <%= render :partial => "contract", :locals => { :agreement => @contract }
+ # within contract we'll get <tt>@contract</tt> in the local variable +contract+, as if we had written
+ #
+ # <%= render :partial => "contract", :locals => { :contract => @contract } %>
+ #
+ # With the <tt>:as</tt> option we can specify a different name for said local variable. For example, if we
+ # wanted it to be +agreement+ instead of +contract+ we'd do:
#
- # The :object option can be used to directly specify which object is rendered into the partial.
+ # <%= render :partial => "contract", :as => :agreement %>
+ #
+ # The <tt>:object</tt> option can be used to directly specify which object is rendered into the partial;
+ # useful when the template's object is elsewhere, in a different ivar or in a local variable for instance.
#
- # Revisiting a previous example we could have written this code.
+ # Revisiting a previous example we could have written this code:
#
# <%= render :partial => "account", :object => @buyer %>
#
# <% for ad in @advertisements %>
# <%= render :partial => "ad", :object => ad %>
# <% end %>
- #
- # The :object and :as options can be used together. We might have a partial which we have named genericly,
- # such as 'form'. Using :object and :as together helps us.
- #
- # <%= render :partial => "form", :object => @contract, :as => :contract %>
+ #
+ # The <tt>:object</tt> and <tt>:as</tt> options can be used together.
+ #
# == Rendering a collection of partials
#
# The example of partial use describes a familiar pattern where a template needs to iterate over an array and