【问题标题】:Haml syntax error | Illegal element: classes and ids must have valuesHaml 语法错误 |非法元素:classes 和 ids 必须有值
【发布时间】:2015-03-11 19:08:10
【问题描述】:
%h3 Regulations

%table.table.table-striped
%thead
%tr
  %th.cls-th-100 Name
  %th.cls-th Title
  %th
  %th
%tbody
- @regulations.each do |regulation|
  %tr
    %td= link_to regulation.name, admin_regulation_path(regulation)
    %td= regulation.title
    %td
      = link_to edit_admin_regulation_path(regulation) do
        %span.glyphicon.glyphicon-edit
    %td
      = link_to admin_regulation_path(regulation), method: :delete, data: { confirm: 'Are you sure?'} do
        %span.glyphicon.glyphicon-trash

我正在尝试注释掉 glyphicon-edit 和 glyphicon-trash,但继续收到错误 Illegal element: classes and ids must have values。

【问题讨论】:

  • 你在倒数第二行的末尾有一些随机的do,并且没有结束卷曲......
  • 此代码(添加缺少的} 后)不会产生该错误。
  • 用于发布目的;我无法添加 } 大括号,所以删除 do?删除了do,它会中断。
  • 它仍然没有产生您声称的错误。
  • @matt - 它还在 config/initializers/quiet_assets.rb call_without_quiet_assets(env).tap do 中读取错误

标签: ruby-on-rails ruby haml


【解决方案1】:

关于关闭 dos 和缺少 curlies 的一些令人困惑的 cmets ...... haml 的要点之一是您不需要关闭标签(或控制语句) - haml 会为您完成。

要在 haml 中发表评论,请在行前加上 -#

-# %span.glyphicon.glyphicon-edit

这是纯红宝石。破折号开始一行 ruby​​ 代码,# 是 ruby​​ 中的注释符号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-27
    • 1970-01-01
    相关资源
    最近更新 更多