2008年1月23日星期三

Haml中的注释

以前一直不知道怎么在Haml中注释掉一段代码。
结果官方文档上写得清清楚楚:
/

The forward slash character, when placed at the beginning of a line, wraps all text after it in an HTML comment. For example:

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

is compiled to:

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

The forward slash can also wrap indented sections of code. For example:

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

is compiled to:

<!--
<p>This doesn't render...</p>
<div>
<h1>Because it's commented out!</h1>
</div>
-->
还是跟缩进相关。

至于反斜杠\(backslash),当然是转义字符啦。
%title
= @title
\- MySite

is compiled to:

<title>
MyPage
- MySite
</title>

具体请参考官方文档:
The full Haml reference
The full Sass reference
The RDoc documentation

没有评论: