passing json data to template
jeremyfrank opened this issue · 2 comments
jeremyfrank commented
Is there a way to add an options for passing json data to a template? Eg:
nav.json:
{
"links": [
{
"href": "page1.html",
"text": "Page 1"
},
{
"href": "page2.html",
"text": "Page 2"
}
]
}
template.hbs
<ul>
{{#each nav.links}}
<li><a href="{{this.href}}">{{this.text}}</a></li>
{{/each}}
</ul>
jamesplease commented
grunt-contrib-handlebars is for precompilation. If you wanted to instead compile the templates then a plugin like grunt-static-handlebars might work better for you.
jeremyfrank commented
Thanks, I was using assemble on the project so I ended up using it to also compile temporary html files, which were then passed to grunt-contrib-handlebars for precompilation. Looks like grunt-static-handlebars could work well.