Reputation: 34934
span_tag = content_tag(:span, class: "123")
It generates the following html:
<span>{:class=>"123"}</span>
I wonder, what's up with this? Shouldn't it be just <span class="123"></span>
which is exactly what I want? Do I necessarily have to use .html_safe
?
Upvotes: 1
Views: 185
Reputation: 44380
From doc
content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
pass empty block:
span_tag = content_tag(:span, class: "123") {}
"<span class=\"123\"></span>"
span_tag = content_tag(:span, class: "123") { 'foo' }
"<span class=\"123\">foo</span>"
Upvotes: 0