2011-11-21 55 views
5

我有這個HAML /鬍子模板:鬍子和Haml的

{{#data}} 
    ok 
    {{#items}} 
    {{#item}} 
     %b ID: {{id}} 
    {{/item}} 
    {{/items}} 
{{/data}} 

而且我有Illegal nesting: nesting within plain text is illegal錯誤。

我呈現在西納特拉

Mustache.render(haml(:index), hash) 
+0

我對你的哈姆感到困惑。 {{是什麼意思? – jaydel

+0

這是鬍鬚:) http://mustache.github.com/ – fl00r

回答

2

我不知道有關與西納特拉渲染,但用這個命令:

cat example.yml foo.haml.mustache | mustache | haml -e 

這個數據文件example.yml

--- 
data: 
    - items: 
    - item: 
     - id: 1 
     - id: 2 
     - id: 3 
---  

和模板(foo.haml.mustache):

{{#data}} 
#ok 
{{#items}} 
{{#item}} 
    %b ID: {{id}} 
{{/item}} 
{{/items}} 
{{/data}} 

我得到以下結果:

<div id='ok'> 
    <b>ID: 1</b> 
    <b>ID: 2</b> 
    <b>ID: 3</b> 
</div> 

請注意在* .mustache文件縮進級別。希望這對你有所幫助。

+2

是的,我明白,我可以刪除所有縮進(標籤),所以它會正常工作。但它是可怕的閱讀:沒有標籤的鬍子:)所以真正的問題是使哈姆工作鬍鬚和它的縮進 – fl00r