put haml tags inside link_to helper

flavaflo picture flavaflo · Mar 8, 2012 · Viewed 23.9k times · Source

is it possible to add html-content inside a link_to helper in HAML?

i tried this, but all i get is a syntax error:

= link_to "Other page", "path/to/page.html"
    %span.icon Arrow

expected output:

<a href="path/to/page.html">Other Page<span class="icon">Arrow</span></a>

Answer

Michał Szajbe picture Michał Szajbe · Mar 8, 2012

You should use block

= link_to "path/to/page.html" do
  Other page
  %span.icon Arrow