Haml-非法嵌套:在纯文本中嵌套是非法的
问题描述:
在使用我的代码在本地计算机上运行的HAML时,我在代码中遇到一个奇怪的错误,但是当我部署它时,出现以下错误
I am facing a weird error in my code while using HAML where my code is working on my Local Machine but when I am deploying it I am getting the following error
ActionView :: Template :: Error(非法嵌套:在纯文本中嵌套是非法的.):
ActionView::Template::Error (Illegal nesting: nesting within plain text is illegal.):
我的代码如下
%td{ :style => 'width:10px' }
= link_to('Dashboard', dashboard_admin_clients_account_path(client)) if client.is_member?
= link_to('Edit', edit_admin_clients_account_path(client))
- if client.removed_at.nil?
= link_to('Delete', admin_clients_account_path(client), :method => :delete, :confirm => 'Are you sure you want to delete')
- else
= link_to('Restore', restore_admin_clients_account_path(client))
我是HAML的新手
答
- 如果您希望链接位于%td内,则应在其右边添加1个标签(td-0个标签,链接-1个标签从左侧开始)
- 您应该使用相同的方法来缩进(例如,始终使用制表符instad).
- 看起来问题不在此代码中.它是部分代码还是部分代码的一部分?
因为这样通常会发生非法嵌套":
%td{ :style => 'width:10px' }
justtext
=link_to ....
尝试以下代码:
%td{ :style => 'width:10px' }
= link_to('Dashboard', dashboard_admin_clients_account_path(client)) if client.is_member?
= link_to('Edit', edit_admin_clients_account_path(client))
- if client.removed_at.nil?
= link_to('Delete', admin_clients_account_path(client), :method => :delete, :confirm => 'Are you sure you want to delete')
- else
= link_to('Restore', restore_admin_clients_account_path(client))