123456789101112131415161718 |
- var koa = require('koa');
- var hbs = require('..');
- var app = koa();
- // koa-hbs is middleware. Use it before you want to render a view
- app.use(hbs.middleware({
- viewPath: __dirname + '/views'
- }));
- // Render is attached to the koa context. Call this.render in your middleware
- // to attach your rendered html to the response body.
- app.use(function *() {
- yield this.render('main', {title: 'koa-hbs'});
- })
- app.listen(3000);
|