Skip to content

Latest commit

 

History

History
109 lines (80 loc) · 2.05 KB

.verb.md

File metadata and controls

109 lines (80 loc) · 2.05 KB

{%= name %} {%= badge("fury") %} {%= badge("travis") %} {%= badge("coverage") %}

{%= description %}

Introduction

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.

Table of contents

Install

{%= include("install-npm", {save: true}) %}

API

See to the API documentation.

{%= apidocs("index.js") %}

Related projects

{%= related(verb.related.list, {remove: name}) %}

Running tests

{%= include("tests") %}

Build docs

Install devDependencies:

npm i -d && verb

Contributing

{%= include("contributing") %}

Authors

{%= include("authors", [ {username: "jonschlinkert"}, {username: "doowb"} ]) %}

License

{%= 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' ]) %}