This project is archived and is in readonly mode.

#871 ✓committed
Tom Lea

content_tag_for should behave like content_tag

Reported by Tom Lea | August 20th, 2008 @ 05:36 PM | in 2.x

The attached patch allows content_tag_for to be used in all cases where content_tag should work.

As it stands calling content_tag_for in a helper, with a block ala...


def voodoo_summary(voodoo)
  div_for(voodoo) do
    h(voodoo.name) + " has " +
    pluralise(voodoo.spells.count, "spells") +
    link_to("[more details on #{voodoo.name}]", voodoo)
  end
end

When this is called from the erb template...


<% @spell_book.voodoo.each do |voodoo| %>
  <%= voodoo_summary(voodoo) %>
<% end %>

We end up getting multiple renders and worse.

Attached patch makes content_tag_for use content_tag in a DRYer way... using it's code to prevent this.

Test included for good luck.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages