我的字形设置如下:
= link_to edit_user_registration_path(pin.user_id), class: "btn btn-default" do
%span.glyphicon.glyphicon-cog
然而,当我把它放在%li中时,我得到了一个非法的嵌套错误:
%ul.nav.navbar-nav.navbar-right.custom
%li= link_to edit_user_registration_path(pin.user_id), class: "btn btn-default" do
%span.glyphicon.glyphicon-cog
我得到以下内容:
Illegal nesting: content can't be both given on the same line as %li and nested within it.
我该如何解决这个问题?
答案 0 :(得分:1)
将link_to
方法放在下一行:
%ul.nav.navbar-nav.navbar-right.custom
%li
= link_to edit_user_registration_path(pin.user_id), class: "btn btn-default" do
%span.glyphicon.glyphicon-cog
生成:
<ul class="nav navbar-nav navbar-right custom">
<li>
<%= link_to edit_user_registration_path(pin.user_id), class: "btn btn-default" do %>
<span class="glyphicon glyphicon-cog"></span>
<% end %>
</li>
</ul>
您可以使用haml2erb.org进行测试。