加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Haml – 非法嵌套:在纯文本内嵌套是非法的

发布时间:2020-12-16 20:22:08 所属栏目:百科 来源:网络整理
导读:我的代码中遇到一个奇怪的错误,而使用HAML,我的代码在我的本地机器上工作,但是当我部署它时,我收到以下错误 ActionView::Template::Error (Illegal nesting: nesting within plain text is illegal.): 我的代码看起来像这样 %td{ :style = 'width:10px' }= l
我的代码中遇到一个奇怪的错误,而使用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的新手

解决方法

>如果您希望您的链接位于%td内,那么它们应该是1张标签(td – 0标签,链接 – 左侧的1个选项卡)
>您应该使用相同的方法来创建缩进(例如,总是使用tab的空格).
看起来好像这个代码中没有问题.是初级还是其他代码的一部分?

因为“非法嵌套”通常发生在你这样做时:

%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',:confirm => 'Are you sure you want to delete')
    - else
        = link_to('Restore',restore_admin_clients_account_path(client))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读