co-render

Thunk-based template rendering for Co and others

npm install co-render
21 downloads in the last day
201 downloads in the last week
811 downloads in the last month

co-render

Template rendering for co using consolidate.js, providing support for dozens of template engines.

Installation

$ npm install co-render

And install whichever engine(s) you use:

$ npm install ejs jade

Example

var co = require('co');
var render = require('co-render');

// swig mapped to .html

co(function *(){
  var user = {
    name: 'tobi',
    species: 'ferret'
  };


  var html = yield render('examples/user.html', { user: user, engine: 'swig' });
  console.log(html);
});

// jade, engine implied by extname

co(function *(){
  var user = {
    name: 'tobi',
    species: 'ferret'
  };


  var html = yield render('examples/user.jade', { user: user });
  console.log(html);
});

// ejs, engine implied by extname, with in-memory cache of the template function

co(function *(){
  var user = {
    name: 'tobi',
    species: 'ferret'
  };


  var html = yield render('examples/user.ejs', { user: user, cache: true });
  console.log(html);
});

License

MIT

npm loves you