这是来自Haml documentation for comments:
评论
Haml 支持两种类型的 cmets:在 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 条件 cmets,方法是将条件括在 / 之后的方括号中。例如:
/[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]-->
Haml 评论:-#
紧跟在井号后面的连字符表示无声的注释。其后的任何文本根本不会呈现在结果文档中。
例如:
%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>
这些是其他参考资料: