soo tired and I know I've seen this before but Google's not helping I'm making a single-page backbone powered WP theme. The data is just the wordpress JSON API data & I've happily used backbone on a few projects now but this time its not playing nice.. It's doing this (showing html tags instead of.. well using them):
here's the render code:
this.template = '<div class="post-list">{{#posts}}<article><h2>{{title}}</h2><span class="postcontent">{{content}}</span></article>{{/posts}}</div>';
if(this.model.get("rawdata").posts!=undefined && this.model.get("rawdata").posts.length>0)
{
var posts = [];
for(i=0;i<this.model.get("rawdata").posts.length;i++)
{
posts[i] = new PostModel(this.model.get("rawdata").posts[i]);
}
this.postCollection = new PostCollection(posts);
this.htm = Mustache.render(this.template,this.model.get("rawdata"));
this.$el.empty().html(this.htm);
log(this.htm)
}
else
{
//handle no-data result error
}
Try putting & before the variable name in the template
{{& posts}}
or
{{& title}}
It's all in the documentation
Another option is to use triple mustaches:
{{{title}}}
It's in the documentation too. This option works in Nustache as well.
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