wxnet2013 / feather-views

Template rendering middleware for koa

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

koa-views

NPM version Dependency Status License

Template rendering middleware for koa.

Supported template engines

Installation

$ npm install koa-views

Example

// Must be used before any router is used
app.use(views('views', {
  map: {
    html: underscore
  }
}));

app.use(function* (next) {
  this.locals = {
    session: this.session,
    title: 'app'
  };

  yield this.render('user', {
    user: 'John'
  });
});

For more examples take a look at the tests

API

views([path, opts])

  • path (__dirname): __dirname + where your views are located
  • opts: these options go straight to co-views.

Debug

Set the DEBUG environment variable to koa-views when starting your server.

$ DEBUG=koa-views

License

MIT

About

Template rendering middleware for koa

License:MIT License


Languages

Language:JavaScript 97.9%Language:Makefile 2.1%