koa-view
Template rendering middleware for koa (using nunjucks).
Installation
$ npm install koa-view
Example
const view = ; // Must be used before any router is usedapp; app;
More examples: tests
API
view(root, opts)
root
: (defaultviews
) Views location. All view yourender()
are relative to this path.opts
nunjucks configure optsopts.ext
: (defaulthtml
) Extension for your view
// instead of thisawait ctx// you canawait ctx
Koa 1 Support
To use koa-view
with koa@1, please use koa-view 1.x.
npm install koa-view@1 --save
License
MIT