0.0.1-alpha.3 • Published 8 years ago

temply-express v0.0.1-alpha.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

temply-express

NPM Version NPM Downloads Travis Build

Temply's HTML template engine for Express.js

How to use it

Easy peasy.

Configure temply-express as a view engine in your Express.js app.js file:

var templyEngineFactory = require('temply-express');
var pluginsRepository = [path.join(__dirname, 'plugins/data'), path.join(__dirname, 'plugins/render')];

var templyEngine = templyEngineFactory(pluginsRepository);
app.engine('html', templyEngine);

// view engine setup
app.set('views', path.join(__dirname, 'templates'));
app.set('view engine', 'html');

Now use it in a route:

router.get('/', function(req, res, next) {
  res.render('index.html');
});

That will look up templates/index.html and call all plugins referenced in it. In this example, plugins will be loaded from plugins/data and plugins/render. The resulting HTML will be written to the HTTP response.