Rails / HAML:link_to帮助器中的image_tag

时间:2013-07-23 00:44:35

标签: ruby-on-rails ruby-on-rails-3 haml

如何在HAML中写这个?

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

我尝试了这个,但失败了:

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

1 个答案:

答案 0 :(得分:7)

这是HAML中的正确方法(请注意do行末尾的link_to):

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