siren-views
v1.0.0
Published
Template rendering middleware for koa.
Downloads
5
Maintainers
Readme
siren-views
Template rendering middleware for koa, modified from koa-views:
- instead of
ctx.locals
, we usectx.state
to store template context. return yield *next
ifctx.render
exists (no matter what the type is).
Example
var koa = require('koa');
var views = require('siren-views');
var app = koa();
app.use(views('views', {
default: 'jade',
map: {
html: underscore
}
}));
app.use(function* (next) {
this.state.session = this.session;
this.state.title = 'app';
yield this.render('user', {
user: 'John'
});
});
API
Please refer to koa-views.
Tests
Tests use mocha and can be run with npm:
npm test