From 6ee06ebec6814576b16f6438c89fb53d557305c2 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 16 Apr 2005 16:08:29 +0000 Subject: 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 --- actionpack/CHANGELOG | 10 ++++++++++ actionpack/lib/action_controller/base.rb | 10 +++++----- actionpack/lib/action_view/partials.rb | 21 ++++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index dd80def3ac..0687be4698 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,15 @@ *SVN* +* Changed render_partial to take local assigns as the second parameter instead of an explicit object and then the assigns. So the API changes from: + + <%= render_partial "account", person, "rules" => regulations.rules %> + + ...to: + + <%= render_partial "account", :account => person, :rules => regulations.rules %> + + The old API will still work, though, and render_partial "account" will still assume :account => @account. + * Added submit_to_remote that allows you to trigger an Ajax form submition at the click of the submission button, which allows for multiple targets in a single form through the use of multiple submit buttons #930 [yrashk@gmail.com] * Fixed pagination to work with joins #1034 [scott@sigkill.org] diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index e7020421c5..c8a012afda 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -242,7 +242,7 @@ module ActionController #:nodoc: cattr_accessor :ignore_missing_templates # Holds the request object that's primarily used to get environment variables through access like - # @request.env["REQUEST_URI"]. + # request.env["REQUEST_URI"]. attr_accessor :request # Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like @params["post_id"] @@ -250,16 +250,16 @@ module ActionController #:nodoc: attr_accessor :params # Holds the response object that's primarily used to set additional HTTP headers through access like - # @response.headers["Cache-Control"] = "no-cache". Can also be used to access the final body HTML after a template - # has been rendered through @response.body -- useful for after_filters that wants to manipulate the output, + # response.headers["Cache-Control"] = "no-cache". Can also be used to access the final body HTML after a template + # has been rendered through response.body -- useful for after_filters that wants to manipulate the output, # such as a OutputCompressionFilter. attr_accessor :response - # Holds a hash of objects in the session. Accessed like @session["person"] to get the object tied to the "person" + # Holds a hash of objects in the session. Accessed like session[:person] to get the object tied to the "person" # key. The session will hold any type of object as values, but the key should be a string. attr_accessor :session - # Holds a hash of header names and values. Accessed like @headers["Cache-Control"] to get the value of the Cache-Control + # Holds a hash of header names and values. Accessed like headers["Cache-Control"] to get the value of the Cache-Control # directive. Values should always be specified as strings. attr_accessor :headers 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 -- cgit v1.2.3