ylluminate ylluminate - 6 months ago 22
Ruby Question

How to apply a link to a multiline text string in HAML?

I have a multiline chunk such as this:

%li
=link_to image_tag("image.jpg", :size => "48x48", :alt => "Something", :title => "Something", :class => "some-class"), some_path
%p.testi
"Some text right here that is divided up onto multiple lines &
%br
and just won't stop running on!”


I need a link to surround both the image and the text. Presently the image link works fine, however on the text link, I believe I have to start with a link_to block, but I'm not seeing the syntax that I should follow there.

How is this correctly done so that all of the multiple lines of text also have a link applied?

Answer

In slim (wich should be similar):

= link_to some_path, class: "some-class" do
    h2 = "#{some_object.title}"
    p.testi
      "Some text right here that is divided up onto multiple lines & 
    br/
    and just won't stop running on!”