本文介绍了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

我的代码如下

  %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. 您应该使用相同的方法来缩进(例如,始终使用制表符instad).
  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))

这篇关于Haml-非法嵌套:在纯文本中嵌套是非法的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 04:31