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
}
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
}
Share
Improve this question
edited May 10, 2012 at 20:53
Alex
asked May 10, 2012 at 20:44
AlexAlex
3,7905 gold badges40 silver badges60 bronze badges
2 Answers
Reset to default 10Try 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.