You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tracend edited this page Sep 18, 2012
·
1 revision
The template class is an "unorthodox" extension of the Backbone.Model . It uses the event listeners but has custom methods for fetching and parsing the data. This is done out of necessity as the data the Template class is most often dealing with are "dum" strings (of markup) and not JSOn as the model class is expecting.
Setup
Before you'll be able to use the Template class there is one piece missing that needs to be configured. That's the compile method for parsing the markup. This is intentionally left out of the Template definition to keep it generic and independent of Template engines.
For example to setup the Template class to use Handlebars:
Template.prototype.compile = Handlebars.compile;
Usage
this.template = new Template(html, options);
html
If 'html' is not empty it will be used as the (only) template necessary and it will be saved as the "default" template for the view.