Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

templates

Eser Ozvataf edited this page May 21, 2015 · 5 revisions

Templates is a container which consists of external template engine such as Hogan, Mustache, Handlebars, etc. It simply behaves as a proxy that enhances inner template engine with some helper methods.

Setting the template engine

Usage: $l.templates.engine = engineName;

// available options: plain, hogan, mustache, handlebars, lodash and underscore.
$l.templates.engine = 'hogan';

Loading a template from DOM element

Usage: $l.templates.apply(element, model[, options])

// let's say it's: Hello {{name}}
var source = $l.id('template-source');
var template = $l.templates.apply(source, { 'name': 'Eser' });
console.log(template);

reads #template-source's contents, applies model on template, returns generated content, then prints: Hello Eser

Clone this wiki locally