Consolidate.js - Express.js Guide: The Comprehensive Book on Express.js (2014)

Express.js Guide: The Comprehensive Book on Express.js (2014)

Consolidate.js

The consolidate library (GitHub) streamlines and generalizes a few dozen template engine modules so they play nicely with Express.js.

The Consolidate.js example:

1 var express = require('express');

2 var consolidate = require('consolidate');

3

4 var app = express();

5

6 //configure template engine:

7 app.engine('html', consolidate.handlebars);

8 app.set('view engine', 'html');

9 app.set('views', __dirname + '/views');

That’s it, res.render() is ready to use Handlebars!

All the template engines that consolidate support as of this writing (taken from its GitHub page):

· atpl

· dust (website)

· eco

· ect (website)

· ejs

· haml (website)

· haml-coffee (website)

· handlebars (website)

· hogan (website)

· jade (website)

· jazz

· jqtpl (website)

· JUST

· liquor

· mustache

· QEJS

· swig (website)

· templayed

· toffee

· underscore (website)

· walrus (website)

· whiskers