diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-04-26 21:24:58 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-04-29 14:45:06 -0300 |
commit | 228f9910389cad7fe0dd7f2bd010fe654f794b37 (patch) | |
tree | af1650d4cf8cd3f77454f05194be288bd3b32a6b /actionpack/lib/action_view/renderer | |
parent | 0568fb5b9efa6923e9407552aae46b0a1210539d (diff) | |
download | rails-228f9910389cad7fe0dd7f2bd010fe654f794b37.tar.gz rails-228f9910389cad7fe0dd7f2bd010fe654f794b37.tar.bz2 rails-228f9910389cad7fe0dd7f2bd010fe654f794b37.zip |
Move layout logic with collection to be handled only with explicit template is given
Layout is never an available option when rendering with the shortcut
`render @collection`.
Diffstat (limited to 'actionpack/lib/action_view/renderer')
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index e2b5e8e36e..2b38834217 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -282,21 +282,7 @@ module ActionView spacer = find_template(@options[:spacer_template]).render(@view, @locals) end - if layout = @options[:layout] - layout = find_template(layout, @locals.keys + [@variable, @variable_counter]) - end - result = @template ? collection_with_template : collection_without_template - - if layout - locals = @locals - result.map! do |content| - locals[@variable] = @collection[result.index(content)] - locals[@variable_counter] = result.index(content) - layout.render(@view, @locals) { content } - end - end - result.join(spacer).html_safe end @@ -391,12 +377,19 @@ module ActionView segments, locals, template = [], @locals, @template as, counter = @variable, @variable_counter + if layout = @options[:layout] + layout = find_template(layout, @locals.keys + [@variable, @variable_counter]) + end + locals[counter] = -1 @collection.each do |object| locals[counter] += 1 locals[as] = object - segments << template.render(@view, locals) + + content = template.render(@view, locals) + content = layout.render(@view, locals) { content } if layout + segments << content end segments |