diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-08-11 23:43:15 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-08-15 12:32:01 -0700 |
commit | 9f5cd0156ab907d8097fc9c588823a9b09038b93 (patch) | |
tree | a240d8f10d15099a3b040a94b66f13d0f570e0ef /actionpack/lib/action_view/render/partials.rb | |
parent | 27adcd1c1a5cc566cfa8c5f8268b65ef01a7e865 (diff) | |
download | rails-9f5cd0156ab907d8097fc9c588823a9b09038b93.tar.gz rails-9f5cd0156ab907d8097fc9c588823a9b09038b93.tar.bz2 rails-9f5cd0156ab907d8097fc9c588823a9b09038b93.zip |
More cleanup of ActionView and reduction in need for blocks in some cases:
* only one of partial_name or :as will be available as a local
* `object` is removed
* Simplify _layout_for in most cases.
* Remove <% render :partial do |args| %>
* <% render :partial do %> still works fine
Diffstat (limited to 'actionpack/lib/action_view/render/partials.rb')
-rw-r--r-- | actionpack/lib/action_view/render/partials.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index e287021eb1..188f0d0214 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -223,16 +223,14 @@ module ActionView def collection_with_template(template) options = @options - segments, locals, as = [], @locals, options[:as] || :object + segments, locals, as = [], @locals, options[:as] || template.variable_name - variable_name = template.variable_name counter_name = template.counter_name locals[counter_name] = -1 collection.each do |object| locals[counter_name] += 1 - locals[variable_name] = object - locals[as] = object if as + locals[as] = object segments << template.render(@view, locals) end @@ -242,14 +240,13 @@ module ActionView def collection_without_template options = @options - segments, locals, as = [], @locals, options[:as] || :object + segments, locals, as = [], @locals, options[:as] index, template = -1, nil collection.each do |object| template = find_template(partial_path(object)) locals[template.counter_name] = (index += 1) locals[template.variable_name] = object - locals[as] = object if as segments << template.render(@view, locals) end @@ -265,8 +262,8 @@ module ActionView @locals[:object] = @locals[template.variable_name] = object @locals[@options[:as]] = object if @options[:as] - content = template.render(@view, @locals) do |*names| - @view._layout_for(names, &@block) + content = template.render(@view, @locals) do |*name| + @view._layout_for(*name, &@block) end return content if @block || !@options[:layout] find_template(@options[:layout]).render(@view, @locals) { content } |