css - Nesting HTML <span> inside rails form_for label tag? -


i want nest element inside form_for label tag. want can target specific portion of label css rules, in case make text red. quick reading, appear valid html, , fits design though idea not playing happily rails.

the desired html output this:
<label for="zip">zip code -<span class="required">required</span></label>

my current code looks this:
<%= form.label :zip, 'zip code -<span class="required">required</span>' %>

the problem rails somehow escaping inner span tag appears text on page instead of html. see on page:
zip code -<span class="required">required</span>

rails3 automatically escapes strings. need call #html_safe on string you're putting in label. see http://yehudakatz.com/2010/02/01/safebuffers-and-rails-3-0/ details.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -