Permalink
Browse files

Added render_partial/render_partial_collection from controllers for e…

…asier Ajaxing

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@880 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 5a4846a commit 7ece0e166d7e65eeaeca5138b7ef0353c598bf95 @dhh dhh committed Mar 9, 2005
Showing with 14 additions and 2 deletions.
  1. +10 −0 actionpack/lib/action_controller/base.rb
  2. +4 −2 actionpack/lib/action_view/partials.rb
@@ -476,6 +476,16 @@ def render_to_string(template_name = default_template_name) #:doc:
add_variables_to_assigns
@template.render_file(template_name)
end
+
+ def render_partial(partial_path, object = nil, local_assigns = {}) #:doc:
+ add_variables_to_assigns
+ render_text(@template.render_partial(partial_path, object, local_assigns))
+ end
+
+ def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = {})#:doc:
+ add_variables_to_assigns
+ render_text(@template.render_collection_of_partials(partial_name, collection, partial_spacer_template, local_assigns))
+ end
# Sends the file by streaming it 4096 bytes at a time. This way the
# whole file doesn't need to be read into memory at once. This makes
@@ -17,7 +17,7 @@ module ActionView
# a partial by the same name as the elements contained within. So the three-lined example in "Using partials" can be rewritten
# with a single line:
#
- # <%= render_collection_of_partials "ad", @advertisements %>
+ # <%= render_partial_collection "ad", @advertisements %>
#
# This will render "advertiser/_ad.rhtml" and pass the local variable +ad+ to the template for display. An iteration counter
# will automatically be made available to the template with a name of the form +partial_name_counter+. In the case of the
@@ -39,7 +39,7 @@ def render_partial(partial_path, object = nil, local_assigns = {})
render("#{path}/_#{partial_name}", { partial_name => object }.merge(local_assigns))
end
- def render_collection_of_partials(partial_name, collection, partial_spacer_template = nil, local_assigns = {})
+ def render_partial_collection(partial_name, collection, partial_spacer_template = nil, local_assigns = {})
collection_of_partials = Array.new
counter_name = partial_counter_name(partial_name)
collection.each_with_index do |element, counter|
@@ -55,6 +55,8 @@ def render_collection_of_partials(partial_name, collection, partial_spacer_templ
end
end
+ alias_method :render_collection_of_partials, :render_partial_collection
+
private
def partial_pieces(partial_path)
if partial_path.include?('/')

0 comments on commit 7ece0e1

Please sign in to comment.