aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-16 16:08:29 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-16 16:08:29 +0000
commit6ee06ebec6814576b16f6438c89fb53d557305c2 (patch)
tree8119a05e75fa1b86485d05debeb0606970dadb93 /actionpack/lib/action_view
parent82456d9392e4abc0a402294c32089b646975eed4 (diff)
downloadrails-6ee06ebec6814576b16f6438c89fb53d557305c2.tar.gz
rails-6ee06ebec6814576b16f6438c89fb53d557305c2.tar.bz2
rails-6ee06ebec6814576b16f6438c89fb53d557305c2.zip
Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1170 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/partials.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb
index cfe53858b4..fa12067c82 100644
--- a/actionpack/lib/action_view/partials.rb
+++ b/actionpack/lib/action_view/partials.rb
@@ -1,14 +1,25 @@
module ActionView
# There's also a convenience method for rendering sub templates within the current controller that depends on a single object
# (we call this kind of sub templates for partials). It relies on the fact that partials should follow the naming convention of being
- # prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own. In the template for
- # Advertiser#buy, we could have:
+ # prefixed with an underscore -- as to separate them from regular templates that could be rendered on their own.
+ #
+ # In a template for Advertiser#account:
+ #
+ # <%= render_partial "account" %>
+ #
+ # This would render "advertiser/_account.rhtml" and pass the instance variable @account in as a local variable +account+ to
+ # the template for display.
+ #
+ # In another template for Advertiser#buy, we could have:
+ #
+ # <%= render_partial "account", :account => @buyer %>
#
# <% for ad in @advertisements %>
- # <%= render_partial "ad", ad %>
+ # <%= render_partial "ad", :ad => ad %>
# <% end %>
#
- # This would render "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display.
+ # This would first render "advertiser/_account.rhtml" with @buyer passed in as the local variable +account+, then render
+ # "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display.
#
# == Rendering a collection of partials
#
@@ -27,7 +38,7 @@ module ActionView
#
# Two controllers can share a set of partials and render them like this:
#
- # <%= render_partial "advertisement/ad", ad %>
+ # <%= render_partial "advertisement/ad", :ad => @advertisement %>
#
# This will render the partial "advertisement/_ad.rhtml" regardless of which controller this is being called from.
module Partials