2011-11-04 100 views
0

我想在部分使用HAML,我寫道:rails 3.1,部分,使用haml?

%p.nested-check-fields 
    = f.input :is_correct 
    = link_to_remove_fields "remove choice", f 

但是,在導致HTML,我得到

<p class="nested-check-fields"> </p> 
<div class="input boolean optional"> 
<input type="hidden" value="0" name="quiz[quiz_choices_attributes][1320389712363][is_correct]"> 
<input id="quiz_quiz_choices_attributes_1320389712363_is_correct" class="boolean optional" type="checkbox" value="1" name="quiz[quiz_choices_attributes][1320389712363][is_correct]"> 
<label class="boolean optional" for="quiz_quiz_choices_attributes_1320389712363_is_correct"> Is correct</label> 
</div> 

的問題是,爲什麼<p class="nested-check-fields"> </p>是空的?我期待將div包裹在裏面,怎麼了?

+0

是不是約定:兩個空格縮進? – apneadiving

回答

0

Haml的是非常嚴格的壓痕(從documentation):

Haml的的缺口可以由一個或多個選項卡或空間。 但是,縮進在給定的文檔中必須一致。硬 選項卡和空格不能混用,並且必須始終使用相同數量的選項卡或空格 。

聽起來好像你實際上可以使用4個空格而不是2個,但這意味着你必須在任何地方使用4個空格(你不能混用它)。我建議只使用2格縮進,因爲這是最常見的縮進。