<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>actionpack/test/fixtures/test/_customer_with_var.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,11 @@
 *Edge*
 
+* Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik]
+
+  render :partial =&gt; 'other_people', :collection =&gt; @people, :as =&gt; :person
+  
+  This will let you access objects of @people as 'person' local variable inside 'other_people' partial template.
+
 * time_zone_select: support for regexp matching of priority zones. Resolves #195 [Ernie Miller]
 
 * Made ActionView::Base#render_file private [Josh Peek]</diff>
      <filename>actionpack/CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -702,6 +702,9 @@ module ActionController #:nodoc:
       #   # builds the complete response.
       #   render :partial =&gt; &quot;person&quot;, :collection =&gt; @winners
       #
+      #   # Renders a collection of partials but with a custom local variable name
+      #   render :partial =&gt; &quot;admin_person&quot;, :collection =&gt; @winners, :as =&gt; :person
+      #
       #   # Renders the same collection of partials, but also renders the
       #   # person_divider partial between each person partial.
       #   render :partial =&gt; &quot;person&quot;, :collection =&gt; @winners, :spacer_template =&gt; &quot;person_divider&quot;
@@ -889,7 +892,7 @@ module ActionController #:nodoc:
             if collection = options[:collection]
               render_for_text(
                 @template.send!(:render_partial_collection, partial, collection,
-                options[:spacer_template], options[:locals]), options[:status]
+                options[:spacer_template], options[:locals], options[:as]), options[:status]
               )
             else
               render_for_text(</diff>
      <filename>actionpack/lib/action_controller/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -252,7 +252,7 @@ module ActionView #:nodoc:
         elsif options[:file]
           render_file(options[:file], use_full_path || false, options[:locals])
         elsif options[:partial] &amp;&amp; options[:collection]
-          render_partial_collection(options[:partial], options[:collection], options[:spacer_template], options[:locals])
+          render_partial_collection(options[:partial], options[:collection], options[:spacer_template], options[:locals], options[:as])
         elsif options[:partial]
           render_partial(options[:partial], ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals])
         elsif options[:inline]</diff>
      <filename>actionpack/lib/action_view/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,10 @@
 module ActionView #:nodoc:
   class PartialTemplate &lt; Template #:nodoc:
-    attr_reader :variable_name, :object
+    attr_reader :variable_name, :object, :as
 
-    def initialize(view, partial_path, object = nil, locals = {})
+    def initialize(view, partial_path, object = nil, locals = {}, as = nil)
       @view_controller = view.controller if view.respond_to?(:controller)
+      @as = as
       set_path_and_variable_name!(partial_path)
       super(view, @path, true, locals)
       add_object_to_local_assigns!(object)
@@ -22,10 +23,11 @@ module ActionView #:nodoc:
     end
 
     def render_member(object)
-      @locals[:object] = @locals[@variable_name] = object
+      @locals[:object] = @locals[@variable_name] = @locals[as] = object
 
       template = render_template
       @locals[@counter_name] += 1
+      @locals.delete(as)
       @locals.delete(@variable_name)
       @locals.delete(:object)
 
@@ -45,6 +47,7 @@ module ActionView #:nodoc:
             else
               object
             end || @view_controller.instance_variable_get(&quot;@#{variable_name}&quot;)
+        @locals[as] ||= @locals[:object] if as
       end
 
       def set_path_and_variable_name!(partial_path)</diff>
      <filename>actionpack/lib/action_view/partial_template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -123,32 +123,32 @@ module ActionView
         end
       end
 
-      def render_partial_collection(partial_path, collection, partial_spacer_template = nil, local_assigns = {}) #:nodoc:
+      def render_partial_collection(partial_path, collection, partial_spacer_template = nil, local_assigns = {}, as = nil) #:nodoc:
         return &quot; &quot; if collection.empty?
 
         local_assigns = local_assigns ? local_assigns.clone : {}
         spacer = partial_spacer_template ? render(:partial =&gt; partial_spacer_template) : ''
 
         if partial_path.nil?
-          render_partial_collection_with_unknown_partial_path(collection, local_assigns)
+          render_partial_collection_with_unknown_partial_path(collection, local_assigns, as)
         else
-          render_partial_collection_with_known_partial_path(collection, partial_path, local_assigns)
+          render_partial_collection_with_known_partial_path(collection, partial_path, local_assigns, as)
         end.join(spacer)
       end
 
-      def render_partial_collection_with_known_partial_path(collection, partial_path, local_assigns)
-        template = ActionView::PartialTemplate.new(self, partial_path, nil, local_assigns)
+      def render_partial_collection_with_known_partial_path(collection, partial_path, local_assigns, as)
+        template = ActionView::PartialTemplate.new(self, partial_path, nil, local_assigns, as)
         collection.map do |element|
           template.render_member(element)
         end
       end
 
-      def render_partial_collection_with_unknown_partial_path(collection, local_assigns)
+      def render_partial_collection_with_unknown_partial_path(collection, local_assigns, as)
         templates = Hash.new
         i = 0
         collection.map do |element|
           partial_path = ActionController::RecordIdentifier.partial_path(element, controller.class.controller_path)
-          template = templates[partial_path] ||= ActionView::PartialTemplate.new(self, partial_path, nil, local_assigns)
+          template = templates[partial_path] ||= ActionView::PartialTemplate.new(self, partial_path, nil, local_assigns, as)
           template.counter = i
           i += 1
           template.render_member(element)</diff>
      <filename>actionpack/lib/action_view/partials.rb</filename>
    </modified>
    <modified>
      <diff>@@ -152,6 +152,10 @@ class NewRenderTestController &lt; ActionController::Base
     render :partial =&gt; &quot;customer&quot;, :collection =&gt; [ Customer.new(&quot;david&quot;), Customer.new(&quot;mary&quot;) ]
   end
 
+  def partial_collection_with_as
+    render :partial =&gt; &quot;customer_with_var&quot;, :collection =&gt; [ Customer.new(&quot;david&quot;), Customer.new(&quot;mary&quot;) ], :as =&gt; :customer
+  end
+
   def partial_collection_with_spacer
     render :partial =&gt; &quot;customer&quot;, :spacer_template =&gt; &quot;partial_only&quot;, :collection =&gt; [ Customer.new(&quot;david&quot;), Customer.new(&quot;mary&quot;) ]
   end
@@ -763,6 +767,11 @@ EOS
     assert_equal &quot;Hello: davidHello: mary&quot;, @response.body
   end
 
+  def test_partial_collection_with_as
+    get :partial_collection_with_as
+    assert_equal &quot;david david davidmary mary mary&quot;, @response.body
+  end
+
   def test_partial_collection_with_counter
     get :partial_collection_with_counter
     assert_equal &quot;david0mary1&quot;, @response.body</diff>
      <filename>actionpack/test/controller/new_render_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -54,6 +54,11 @@ class ViewRenderTest &lt; Test::Unit::TestCase
   def test_render_partial_collection
     assert_equal &quot;Hello: davidHello: mary&quot;, @view.render(:partial =&gt; &quot;test/customer&quot;, :collection =&gt; [ Customer.new(&quot;david&quot;), Customer.new(&quot;mary&quot;) ])
   end
+  
+  def test_render_partial_collection_as
+    assert_equal &quot;david david davidmary mary mary&quot;, 
+      @view.render(:partial =&gt; &quot;test/customer_with_var&quot;, :collection =&gt; [ Customer.new(&quot;david&quot;), Customer.new(&quot;mary&quot;) ], :as =&gt; :customer)
+  end
 
   # TODO: The reason for this test is unclear, improve documentation
   def test_render_partial_and_fallback_to_layout</diff>
      <filename>actionpack/test/template/render_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4f75840d72b96fff34d65b59480da7d6c7494120</id>
    </parent>
  </parents>
  <author>
    <name>Pratik Naik</name>
    <login>lifo</login>
    <email>pratiknaik@gmail.com</email>
  </author>
  <url>http://github.com/rails/rails/commit/2b43620e3c1352028f19550fcde4632d65cbd191</url>
  <id>2b43620e3c1352028f19550fcde4632d65cbd191</id>
  <committed-date>2008-07-02T08:40:42-07:00</committed-date>
  <authored-date>2008-07-02T08:38:50-07:00</authored-date>
  <message>Add :as option to render a collection of partials with a custom local variable name. [#509 state:resolved] [Simon Jefford, Pratik Naik]</message>
  <tree>b28ddcc92eae7fe9ceea11c2f55b1956f5d4efc7</tree>
  <committer>
    <name>Pratik Naik</name>
    <login>lifo</login>
    <email>pratiknaik@gmail.com</email>
  </committer>
</commit>
