package
Add a `render()` method to koa that allows you to render almost any templating engine
npm install koa-renderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Add a render() method to koa that allows you to render almost any templating engine.
Extending koa by adding a render() method has the advantage that you can define your views settings once and have them available in each of your koa sub-apps.
$ npm i --save koa-renderUse views in a koa middleware with given options and yield it to this.body. Koa-render finds your given template relative to the path that you set. engine can be any templating engine that is supported by consolidate.js
app.use(views('./example', 'jade'));
app.use(router.get('/', function *(next) {
this.body = yield this.render('index');
}));Note: Make sure that you define views() before you mount other koa apps.
For a full example take a look at the ./example folder.
MIT