{%= description %}
Here is a brief example of what you can do with Template.
var app = require('template')();
app.engine('tmpl', require('engine-lodash'));
/**
* Create a custom view collection
*/
app.create('pages');
/**
* Load views onto the collection (globs work too)
*/
app.page('welcome.tmpl', {path: 'welcome.tmpl', content: 'Hello, <%= name %>!'})
.page('goodbye.tmpl', {path: 'goodbye.tmpl', content: 'Goodbye, <%= name %>!'});
// get a template
var page = app.pages.get('welcome.tmpl');
// render the template
page.render({name: 'Bob'}, function (err, res) {
if (err) return console.log(err);
console.log(res.content);
//=> 'Hello, Bob!'
app.pages.get('goodbye.tmpl')
.render({name: 'Bob'}, function (err, res) {
if (err) return console.log(err);
console.log(res.content);
//=> 'Goodbye, Bob!'
});
});
Docs are on the way. In the meantime, visit the examples and unit tests to learn more about what Template can do.
{%= include("install-npm", {save: true}) %}
See to the API documentation.
{%= apidocs("index.js") %}
{%= related(verb.related.list, {remove: name}) %}
{%= include("tests") %}
Install devDependencies:
npm i -d && verb
{%= include("contributing") %}
{%= include("authors", [ {username: "jonschlinkert"}, {username: "doowb"} ]) %}
{%= copyright({year: 2014, linkify: true}) %} {%= license({linkify: true}) %}
{%= include("footer") %}
// example.data
console.log(template.cache.data);
//=> {};
template.data('a', 'b');
template.data({c: 'd'});
console.log(template.cache.data);
//=> {a: 'b', c: 'd'}
{%= reflinks([ 'engine-cache', 'engine-noop', 'consolidate', 'transformers', 'parse-files', 'parser-cache', 'parser-front-matter', 'parser-noop', 'verb' ]) %}