Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using handlebars with backbone block collection
// Reference:
// http://stackoverflow.com/questions/7344982/questions-on-backbone-js-with-handlebars-js
var ArticleListView = Backbone.View.extend({
el: $('#main'),
render: function(){
var js = this.collection.toJSON();
var template = Handlebars.compile($("#some-template").html());
$(this.el).html(template({articles: js}));
return this;
}
});
// Sample Handlebars Template
/**
<script id="some-template" type="text/x-handlebars-template">
{{#each articles}}
{{this.title}}
{{/each}}
</script>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment