RoR 3 - f.label embeds an <span> tag - howto
How would i do the following.
My current code is :
<%= f.label :email, html_escape("<span class=\"big\">Test</span>") %>
This doesn't shows what i want, because the
<span class=\"big\">Test</span>
is shown as text instead of HTML.
I have been thinking of overriding the FormBuilder, but i don't know how i would do this and searching for something similar hasn't solved my problems.
Also, instead of Test i want to show the variabel: email.
I just want to solve the problem that i have :)
PS. I'm usi开发者_Python百科ng Rails 3.0.
All helper in rails 3 are html_escape, so it's not anymore needed.
don't use html_escape and it's works fine. You need use raw
<%= f.label :email, raw("<span class=\"big\">Test</span>") %>
Or you can mark this chain as safe
<%= f.label :email, "<span class=\"big\">Test</span>".html_safe %>
You are html_escape
'ing the span...that is why the span html is showing up on your page. If you get rid of that, it'll just render as html, which is what you want.
精彩评论