我有
<div class="navbar-brand">
<a href="#{root_path}">
<img src="tree.png" id="icon">
City Park
</a>
</div>
我不明白它是如何写在HAML的
应该:
.navbar-brand
%a{:href => "#{root_path}"}
%img#icon{:src => "tree.png"}
City Park
更新2019年
.navbar-brand
%a{href: root_path}
%img#icon{src: "tree.png"}
City Park
试试这个:
.navbar-brand
= link_to ("#{'City Park'} #{image_tag 'tree.png', :id => 'icon'}").html_safe, root_path
简短而简单:-)