Reputation: 4578
I am trying to apply an html tag to a substring of a rails form_for
label, in the following context.
=f.label :question_7, "The Portrait of a Lady _ Henry James, an American author."
When I would like to do the following
"<i> The Portrait of a Lady </i> _ Henry James, an American author."
I tried using the #{}
string interpolation operator and putting %i
in there but that doesn't work and neither is it an intuitive solution. I similarly tried to vanilla HTML tags in the string which also doesn't work. If I wrap the tag in quotes, it just places the tag itself in the string, and if I don't, the view blows up saying it doesn't expect a <
brace which makes sense cause its haml.
Thanks for your help!
Upvotes: 0
Views: 156
Reputation: 19889
One way using html_safe
. I'm sure there are other ways using content_tag
as well.
= f.label :question_7, "<i>The Portrait of a Lady</i> _ Henry James, an American author.".html_safe
Or, use a block:
= f.label :question_7 do
%i The Portrait of a Lady
_ Henry James, an American author
Upvotes: 1