diff options
author | Sergio Arbeo <serabe@gmail.com> | 2012-03-06 16:20:56 +0100 |
---|---|---|
committer | Sergio Arbeo <serabe@gmail.com> | 2012-03-06 16:20:56 +0100 |
commit | e4e1388318cd281bf27114b608487330ae1a58df (patch) | |
tree | 2553f9a30fcd2b47764e11b9b2b044c712a3463a /actionpack/lib/action_view | |
parent | dc8071520761d954d0958316a45aa9223b70a3d1 (diff) | |
download | rails-e4e1388318cd281bf27114b608487330ae1a58df.tar.gz rails-e4e1388318cd281bf27114b608487330ae1a58df.tar.bz2 rails-e4e1388318cd281bf27114b608487330ae1a58df.zip |
Adds :layout option to render :partial when a collection is given.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index 3628b935b7..ac4c8db50e 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -238,7 +238,14 @@ module ActionView spacer = find_template(@options[:spacer_template]).render(@view, @locals) end + if layout = @options[:layout] + layout = find_template(layout) + end + result = @template ? collection_with_template : collection_without_template + + result.map!{|content| layout.render(@view, @locals) { content } } if layout + result.join(spacer).html_safe end @@ -342,9 +349,10 @@ module ActionView locals[as] = object segments << template.render(@view, locals) end - + segments end + def collection_without_template segments, locals, collection_data = [], @locals, @collection_data |