Losing the engine
Closed this issue · 2 comments
Testing this out I have this code:
app.use(views('../views'), {
html: 'underscore'
});
app.use(function *(next) {
this.body = yield this.render('index', { name: 'koa' });
});
and grapped in the index.html file from the Underscore example. But when I open the page I get this error:
TypeError: undefined is not a function
at Object. (/Users/thomas/CloudStation/Dropbox/www/webBlueprint/node_modules/koa-render/node_modules/co-views/node_modules/co-render/index.js:33:5)
at next (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:74:19)
at Object. (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:91:5)
at next (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:74:19)
at Object. (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:91:5)
at next (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:74:19)
at Object. (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:91:5)
at next (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:74:19)
at Object. (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:91:5)
at next (/Users/thomas/CloudStation/Dropbox/www/koala/node_modules/koa/node_modules/co/index.js:74:19)
I enable Debug and got this:
<-- GET /
co-views views ../views {} +0ms
co-views render ../views/index.html {"name":"koa","engine":"html","cache":false} +0ms
co-render render ../views/index.html with {"name":"koa","engine":"html","cache":false} +0ms
--> GET / 200 2ms -
So somewhere the underscore engine is lost and the example doesn't work? Or am I doing something wrong?
Your code is like this:
app.use(views('../views'), {
html: 'underscore'
});
when it should be like this:
app.use(views('../views', {
html: 'underscore'
}));
The object is a parameter of the .views()
fn, not the .use()
fn.
Wow, that was stupid. Should have seen that, closing.