1.0.0 • Published 9 months ago
connect-renderer v1.0.0
connect-renderer
Connect compatible implementation of template renderer. Inspired and based on res.render() implementation in Express
To be used where entire express functionality is not needed.
Install
$ npm install --save connect-rendererUsage
const connect = require('connect');
const app = connect();
const renderer = require('connect-renderer');
app.use(renderer(VIEWS_DIR).engine('pug', {
  compile: require('pug').compile,
  options: {
    // all options are passed to `compile` function
    compileDebug: process.env.NODE_ENV !== 'production'
  }
}));
app.use('/page', (req, res) => {
  // req.app.locals and res.locals are merged with options passed to `render`
  res.render('page', { title: 'Page'});
})License
MIT © Damian Krzeminski