Search code examples
ruby-on-railsruby-on-rails-3haml

Rails / HAML: image_tag inside a link_to helper


How do I write this in HAML?

<a class="pull-left" href="#">
  <img class="media-object" data-src="holder.js/64x64">
</a>

I tried this but it failed:

=link_to "#", :class => "pull-left
 =image_tag "64x64.gif", :class => "media-object"

Solution

  • This is the correct way in HAML (note the do at the end of link_to line):

    = link_to "#", :class => "pull-left" do
      = image_tag "64x64.gif", :class => "media-object"