Ruby-on-rails Haml -非法嵌套:在纯文本中嵌套是非法的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13524161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Haml -Illegal nesting: nesting within plain text is illegal
提问by Arihant Godha
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
我在使用 HAML 时在我的代码中遇到了一个奇怪的错误,其中我的代码在我的本地机器上工作,但是当我部署它时,我收到以下错误
ActionView::Template::Error (Illegal nesting: nesting within plain text is illegal.):
ActionView::Template::Error(非法嵌套:在纯文本中嵌套是非法的。):
My code looks like this
我的代码看起来像这样
%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))
I am new to HAML
我是 HAML 的新手
采纳答案by vekozlov
- If you want your links to be inside the %td, they should be 1 tab righter (td - 0 tab, links - 1 tabs from the left side)
- you should use the same method to make indents (for example always use tab instad of spaces).
- it looks like the problem is not in this code. Is it partitial or part of some other code?
- 如果您希望您的链接位于 %td 内,则它们应该靠右 1 个标签(td - 0 个标签,链接 - 从左侧开始 1 个标签)
- 您应该使用相同的方法进行缩进(例如始终使用制表符插入空格)。
- 看起来问题不在这段代码中。它是部分代码还是其他代码的一部分?
Because 'illegal nesting' usually happens when you do like this:
因为当您这样做时,通常会发生“非法嵌套”:
%td{ :style => 'width:10px' }
justtext
=link_to ....
Try this code:
试试这个代码:
%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))

