123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- var hbs = require('../../index');
- var koa = require('koa');
- var router = require('koa-router');
- var create = function(opts) {
- var app = koa();
- var _hbs = hbs.create();
- app.on('error', function(err) {
- console.error(err.stack);
- });
- app.use(_hbs.middleware(opts));
- app.use(router(app));
- app.get('/', function*() {
- yield this.render('main', {title: 'test'});
- });
- app.get('/partials', function*() {
- yield this.render('mainWithPartials', {
- title: 'test',
- anchorList:[
- {url: 'https://google.com', name: 'google'},
- {url: 'https://github.com', name: 'github'}
- ]
- });
- });
-
- app.get('/nestedPartials', function*() {
- yield this.render('nestedPartials' );
- });
- app.get('/layout', function *() {
- yield this.render('useDefaultLayout');
- });
- app.get('/altLayout', function *() {
- yield this.render('useAlternativeLayout');
- });
- app.get('/block', function *() {
- yield this.render('usesBlockLayout');
- });
- app.get('/blockNoReplace', function *() {
- yield this.render('usesBlockLayoutNoBlock');
- });
- app.get('/empty', function *() {
- yield this.render('empty');
- });
- app.get('/locals', function *() {
- yield this.render('locals');
- });
- app.get('/localsOverride', function *() {
- yield this.render('locals', {
- title: 'Bar'
- });
- });
- app.get('/localsRecursive', function *() {
- var obj = {};
- obj.title = 'Bar';
- obj.recursive = obj;
- yield this.render('locals', obj);
- });
- return app;
- };
- exports.create = create;
|