rails/rails — pull request #5310 by Serabe (2012-03-06 22:48:36+00:00)
Title: Adds :layout option to render :partial when a collection is given.

## Short story

Adds support for layout option when rendering a partial for a collection.

## Long story

I had a view like this one:

```erb

<% collection.each do | item | -%>

<%= render partial: 'a_partial', object: item %>

<% end -%>

```

But it felt wrong using an iterator with just a partial inside. Currently, for cleaning this up you would need a partial like

```erb

```

and modify the original view to use a spacer_template

```erb

<%= render partial: 'a_partial', object: item, spacer_template: 'li_spacer_template' %>

```

But it still felt wrong since spacer template is not valid html, so I thought of using a simple layout like this one:

```erb

<%= yield %>

```
When I realized that render partial has no layout option when a collection is given. This pull request adds it and now, code like this is allowed:

```erb

<%= render partial: 'a_partial', object: item, layout: 'li_layout' %>

```

It is shorter and seems better to me.