ruby on rails - How to render HTML inside Slim templates -


i'm trying render link preceded icon. i'm using slim templating engine along bootstrap css.

usually following way:

<a href="#"><i class="icon-user"></i> profile</a> 

according slim's documentation, can use == render without escaping html. so, translating slim, tried following variations:

li== link_to "<i class='icon-user'></i> profile", current_user li== link_to "#{'<i class="icon-user"></i>'.html_safe} profile", current_user li= link_to "#{'<i class="icon-user"></i>'.html_safe} profile", current_user 

all variations rendered <a href="/users/1"><i class="icon-user"></i> profile</a> escaping i tag.

how can stop slim or rails escaping html?

(rails 3.2 slim 1.2.1)

you want disable html escaping link_to argument, not entire link_to result. you're pretty close html_safe string interpolation eating "safe html" flag. should work better:

li= link_to '<i class="icon-user"></i> profile'.html_safe, current_user 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -