siren-views

1.0.0 • Public • Published

siren-views

Build Status

Template rendering middleware for koa, modified from koa-views:

  • instead of ctx.locals, we use ctx.state to store template context.
  • return yield *next if ctx.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

License

MIT

Package Sidebar

Install

npm i siren-views

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • texvnars