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)
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:
<div id='ok'>
<b>ID: 1</b>
<b>ID: 2</b>
<b>ID: 3</b>
</div>
Pls pay attention to indentation level in *.mustache file. Hope this help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With