The content_tag helper allows you to do things like:
content_tag(:p, "Hello world!")
# => <p>Hello world!</p>
It can take in blocks, for functionality like this:
<% content_tag :div, :class => "strong" do -%>
Hello world!
<% end -%>
# => <div class="strong"><p>Hello
world!</p></div>
Unfortunately blocks only work in erb and not as helper methods. This
problem already has a ticket http://dev.rubyonrails.org/ticket/7432
Greg Pierce has come up with a fix
http://greg.agiletortoise.com/2007/03/01/rails-content_tag-block-fix but
I''m looking for more.
I''d like to write something along the lines of
content_tag :table do
content_tag :tr do
content_tag :td, "first"
content_tag :td, "second"
end
end
With Greg''s fix, that code doesn''t crash at least, but the
block.call
line only returns the second td tag. I generally understand what the
problem is, but my skills with Ruby blocks are coming up short. Anyone
have an idea how to fix this?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---