gpt4 book ai didi

ruby-on-rails - Haml - 非法嵌套 : nesting within plain text is illegal

转载 作者:行者123 更新时间:2023-12-03 07:04:58 31 4
gpt4 key购买 nike

在使用 HAML 时,我的代码中遇到了一个奇怪的错误,其中我的代码在本地计算机上运行,​​但当我部署它时,我收到以下错误

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 新手

最佳答案

  1. 如果您希望链接位于 %td 内,则它们应位于右侧 1 个选项卡(td - 0 个选项卡,链接 - 左侧 1 个选项卡)
  2. 您应该使用相同的方法进行缩进(例如始终使用制表符而不是空格)。
  3. 看起来问题不在这段代码中。它是部分代码还是其他代码的一部分?

因为当您这样做时通常会发生“非法嵌套”:

%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))

关于ruby-on-rails - Haml - 非法嵌套 : nesting within plain text is illegal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13524161/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com