Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move layout logic with collection to be handled only with explicit te…

…mplate is given

Layout is never an available option when rendering with the shortcut
`render @collection`.
  • Loading branch information...
commit 228f9910389cad7fe0dd7f2bd010fe654f794b37 1 parent 0568fb5
@carlosantoniodasilva authored
Showing with 8 additions and 15 deletions.
  1. +8 −15 actionpack/lib/action_view/renderer/partial_renderer.rb
View
23 actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -282,21 +282,7 @@ def render_collection
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 @@ def collection_with_template
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
Please sign in to comment.
Something went wrong with that request. Please try again.