I'm trying to render a link preceded by an icon. I'm using Slim templating engine along with Bootstrap CSS.
Usually you could do this the following way:
<a href="#"><i class="icon-user"></i> My Profile</a>
According to Slim's documentation, we can use ==
to render without escaping HTML. So, translating this to Slim, I tried the following variations:
li== link_to "<i class='icon-user'></i> My Profile", current_user
li== link_to "#{'<i class="icon-user"></i>'.html_safe} My Profile", current_user
li= link_to "#{'<i class="icon-user"></i>'.html_safe} My Profile", current_user
All variations rendered <a href="/users/1"><i class="icon-user"></i> My Profile</a>
escaping the i
tag.
How can I stop Slim or Rails from escaping html?
(Rails 3.2 with Slim 1.2.1)