0

想知道如何在 HALMC 中注释掉一行。我试过了

# this is commented out

但它不起作用。<div> this is commented out </div> 它会在 HALMC 上创建一个Can't find many resources。

知道如何注释掉多行也将不胜感激。

4

2 回答 2

2

这是来自Haml 文档的评论

注释

Haml 支持两种类型的注释:在 HTML 输出中显示的和不显示的。

HTML 评论:/

正斜杠字符在放置在行首时,会将其后的所有文本包装在 HTML 注释中。例如:

%peanutbutterjelly
  / This is the peanutbutterjelly element
  I like sandwiches!

编译为:

<peanutbutterjelly>
  <!-- This is the peanutbutterjelly element -->
  I like sandwiches!
</peanutbutterjelly>

正斜杠还可以包裹缩进的代码段。例如:

/
  %p This doesn't render...
  %div
    %h1 Because it's commented out!

编译为:

<!--
  <p>This doesn't render...</p>
  <div>
    <h1>Because it's commented out!</h1>
  </div>
-->

条件注释:/[]

您还可以通过在 / 之后将条件括在方括号中来使用 Internet Explorer 条件注释。例如:

/[if IE]
  %a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
    %h1 Get Firefox

编译为:

<!--[if IE]>
  <a href='http://www.mozilla.com/en-US/firefox/'>
    <h1>Get Firefox</h1>
  </a>
<![endif]-->

哈姆评论:-#

紧跟在英镑后面的连字符表示无声评论。其后的任何文本根本不会呈现在结果文档中。

例如:

%p foo
-# This is a comment
%p bar

编译为:

<p>foo</p>
<p>bar</p>

您还可以在无声评论下嵌套文本。不会呈现此文本。例如:

%p foo
-#
  This won't be displayed
    Nor will this
                   Nor will this.
%p bar

编译为:

<p>foo</p>
<p>bar</p>

这些是其他参考:

于 2015-09-25T10:15:54.357 回答
1

您可以像这样评论该行

对于haml标签

//%div

和 rails 标签

=# link_to "", ""

这是haml的注释代码

于 2015-09-25T10:04:01.190 回答