koa-generic-views
generic view interface for koa
Install
npm i koa-generic-views --save
API
var views = ;;
Options
- viewRoot: set the root path
- defaultExt: set the default extension
- cache: when final locals don't have
cache
field, get cache flag fromopts.cache
, then get cache fromprocess.env.NODE_ENV
Example
var koa = ;var app = ;var jade = ;app defaultExt: 'jade'; // reutrn plain valuesapp; // or Promiseapp; // or simply use bluebird, Promise.promisifyvar Promise = ;app; app;
app.engine('ext',engine);
engine should return a value or a Promise
so use Promise.promisify
with bluebird is also supported.
Why
why not koa-views?
koa-views -> co-views -> co-render -> consolidate.js
Any engine not supported in consolidate need to PR to consolidate.I hate centerlized.
Changelog
License
the MIT License http://magicdawn.mit-license.org