Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

connect-renderer

pirxpilot26MIT1.0.0

Connect compatible implementation of template renderer.

connect-renderer, connect, express, render, template, jade, pug, handlebars

readme

NPM version Build Status Dependency Status

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-renderer

Usage

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