<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: tag code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 01:38:06 GMT</pubDate>
    <description>DZone Snippets: tag code</description>
    <item>
      <title>content_tag that accepts a block = block_tag</title>
      <link>http://snippets.dzone.com/posts/show/1910</link>
      <description>Sometimes I want to do something like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;% content_tag("div", :class =&gt; "section_with_error" do %&gt;&lt;br /&gt;  HTML GOES HERE&lt;br /&gt;&lt;% end %&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;instead of this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;%= content_tag("div", "HTML GOES HERE", :class =&gt; "section_with_error") %&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Put the following code in ApplicationHelper, and you can do just that (replacing "content_tag" in the example above with "block_tag", of course):&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def block_tag(tag, options = {}, &amp;block)&lt;br /&gt;    concat(content_tag(tag, capture(&amp;block), options), block.binding)&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 13 Apr 2006 02:08:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1910</guid>
      <author>canadaduane (Duane Johnson)</author>
    </item>
  </channel>
</rss>
