【问题标题】:Comment out an item in table on haml注释掉haml表中的一个项目
【发布时间】:2016-12-10 06:40:26
【问题描述】:

你有一张关于haml的桌子。

  %table
    %tr
      %th HOGE1
      %th HOGE2
      %tr
        %td HAGE1
        %td HAGE2

现在您要注释掉第一项。

      %table
        %tr
-#          %th HOGE1
          %th HOGE2
          %tr
-#            %td HAGE1
            %td HAGE2

...

为什么它不起作用.....?

【问题讨论】:

  • -#%th之间不能有空格
  • 您的注释应该缩进到您的代码级别,因为 haml 可以缩进
  • 感谢您的建议。这完全消除了我的痛苦。

标签: ruby-on-rails ruby comments haml


【解决方案1】:

-# 和 %th 之间不能有空格 试试:

%table
  %tr
    -#%th HOGE1
    %th HOGE2
  %tr
    -#%td HAGE1
    %td HAGE2

输出html:

<table>
  <tr>
    <th>HOGE2</th>
  </tr>
  <tr>
    <td>HAGE2</td>
  </tr>
</table>

#- 将省略相应的行。 /将注释掉该行并生成html注释

%table
  %tr
    /%th HOGE1
    %th HOGE2
  %tr
    / %td HAGE1
    %td HAGE2

输出html: <table> <tr> <!-- %th HOGE1 --> <th>HOGE2</th> </tr> <tr> <!-- %td HAGE1 --> <td>HAGE2</td> </tr> </table>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-23
    • 2021-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-08
    • 2013-11-18
    相关资源
    最近更新 更多