Returns an HTML block tag of type
name surrounding the content. Add HTML attributes by
passing an attributes hash to options. Instead of passing the
content as an argument, you can also use a block in which case, you pass
your options as the second parameter. Set escape to false to
disable attribute value escaping.
Options
The options hash is used with attributes with no value like
(disabled and readonly), which you can give a value of
true in the options hash. You can use symbols or strings for the
attribute names.
Examples
content_tag(:p, "Hello world!")
# => <p>Hello world!</p>
content_tag(:div, content_tag(:p, "Hello world!"), :class => "strong")
# => <div class="strong"><p>Hello world!</p></div>
content_tag("select", options, :multiple => true)
# => <select multiple="multiple">...options...</select>
<% content_tag :div, :class => "strong" do -%>
Hello world!
<% end -%>
# => <div class="strong">Hello world!</div>