Package Exports
- koa-views
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (koa-views) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
koa views
Render views with almost any templating engine.
Installation
$ npm install koa-viewsExample
app.use(views('views', {
default: 'jade',
cache: true,
map: {
html: underscore
}
}));
app.use(function* (next) {
this.locals = {
session: this.session,
title: 'app'
};
console.log(this.locals); // {session: {_id: ...}, title: app}
// Render html with underscore.
yield this.render('index.html', {
user: 'John'
});
// Render jade.
yield this.render('index', {
user: 'Prick'
});
});For full examples take a look at the ./examples folder.
API
views([path, opts])
path (__dirname): __dirname + where your views are locatedopts: these options go straight to co-views.
Debug
$ DEBUG=koa-views node --harmony-generators server.jsLicence
MIT