Haml -Illegal nesting: nesting within plain text is illegal

一曲冷凌霜 提交于 2019-12-08 15:48:49

问题


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 (Illegal nesting: nesting within plain text is illegal.):

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


回答1:


  1. 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)
  2. you should use the same method to make indents (for example always use tab instad of spaces).
  3. it looks like the problem is not in this code. Is it partitial or part of some other code?

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


来源:https://stackoverflow.com/questions/13524161/haml-illegal-nesting-nesting-within-plain-text-is-illegal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!