aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index 34ea06c9cf..449cf08fd0 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -283,13 +283,19 @@ module ActionView
end
if layout = @options[:layout]
- layout = find_template(layout)
+ layout = find_template(layout, @locals.keys + [@variable])
end
result = @template ? collection_with_template : collection_without_template
-
- result.map!{|content| layout.render(@view, @locals) { content } } if layout
-
+
+ if layout
+ locals = @locals
+ result.map! do |content|
+ locals[@variable] = @collection[result.index(content)]
+ layout.render(@view, @locals) { content }
+ end
+ end
+
result.join(spacer).html_safe
end
@@ -391,10 +397,9 @@ module ActionView
locals[as] = object
segments << template.render(@view, locals)
end
-
+
segments
end
-
def collection_without_template
segments, locals, collection_data = [], @locals, @collection_data