Mustache and Haml

匿名 (未验证) 提交于 2019-12-03 01:47:02

问题:

I have got this haml/mustache template:

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

And I have got Illegal nesting: nesting within plain text is illegal Error.

I render it in Sinatra

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

回答1:

I'm not sure about rendering with Sinatra, but with this command:

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

this data file example.yml

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

and template (foo.haml.mustache ):

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

I get following result:

ID: 1 ID: 2 ID: 3

Pls pay attention to indentation level in *.mustache file. Hope this help you.



文章来源: Mustache and Haml
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!