Q:

How to make HAML output HTML as HTML, not encoded text

Most of my HAML works just fine, but the following line...
%td= user.roles.map { |r| link_to(r.name, r)}.join(', ')

...returns...
<td>
  &lt;a href=&quot;/roles/1&quot;&gt;admin&lt;/a&gt;
</td>

...when naturally I want it to return...
<td>
  <a href='/roles/1'>
    admin
  </a>
</td>

The following does not fix the situation:
%td= user.roles.map { |r| link_to(r.name, r).html_safe}.join(', ')

What should I do?
Steven.

A:

%td= user.roles.map { |r| link_to(r.name, r)}.join(', ').html_safe

Be careful about having all this logic in the view, though. You can accomplish a similar goal either by rendering a partial for each item in a collection, or by creating a helper method for you. It would read much cleaner as:
%td= role_links_for_user

or
= render user.roles

