Closed tomgp closed 10 years ago
You should be able to use Backbone Models
and Collections
if you wish. The only requirement is that the 'Model' you assign to a view has a .toJSON
method (which I believe Backbone collections do). FruitMachine will call this method just before templating, and pass the output as the first parameter to your template function.
var Apple = fruitmachine.define({
name: 'apple',
template: function(json) {
return '<h1>' + json.title + '</h1>'
}
});
var model = new backbone.Model({ title: 'hello world' });
var apple = new Apple({ model: model });
apple.render();
apple.el.innerHTML; //=> '<h1>hello world</h1>';
OK, that seems reasonable, thanks.