"prettyprint lang-js">
var templates = {
  template1: Handlebars.compile(...),
  template2: Handlebars.compile(...),
  template2: Handlebars.compile(...),
  ...
};

var options = {
  template: function (item, element, data) {
    var template = templates[item.template];  // choose the right template
    return template(item);                    // execute the template
  }
};
</pre>

  Now the items can be extended with a property <code>template</code>, specifying which template to use for the item.


  <h2 