I love the HAML-like syntax of Jade\'s templating engine in Node.js, and I would love to use it client-side within Backbone.js.
I\'ve seen Backbone commonly using Un
I was able to run Jade client-side using jade-browser project.
Integration with Backbone is then simple: Instead of _template() I'm using jade.compile().
HTML (scripts and template):
JavaScript (integration with Backbone.View):
var jade = require("jade");
var TestView = Backbone.View.extend({
initialize: function() {
this.template = jade.compile($("#test").text());
},
render: function() {
var html = this.template({ item: 'hello, world'});
$('body').append(html);
}
});
var test = new TestView();
test.render();
HERE is the code.