2015-09-25 80 views
0

想知道如何註釋掉HAMLC中的一行。 我試過了如何在HAMLC註釋掉一行註釋

# this is commented out 

但它不起作用。它會創建一個<div> this is commented out </div> 在HAMLC上找不到許多資源。

瞭解如何評論多行也值得讚賞。

+0

@antonie你嘗試:%P代碼行-1 - #這是一條評論 %p code-line-2 – alexandresaiz

回答

1

ŧ他是從Haml documentation for comments

評論

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]--> 

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> 

這些都是其他參考資料:

+1

明確表明內容來源非常重要。我強烈建議清楚地說明這是從哪裏來的,最好在答案的頂部。 –

+0

對不起。我會添加答案來自。謝謝@theTinMan。 – akbarbin

1

你可以發表評論像

行對於HAML標籤

//%div

和軌道標籤

=# link_to "", ""

這裏是一個comment code of haml