Closed ilkkao closed 8 years ago
this is a good find, thanks. not sure if I'll have time to get tests in place and make a fix until the weekend - if you'd like to create a PR in the meantime it'd be welcome!
In my app I fixed this by switching from the problematic config:
app.use(hbs.middleware({
defaultLayout: 'layouts/main',
viewPath: path.join(__dirname, 'views')
}));
to
app.use(hbs.middleware({
layoutsPath: path.join(__dirname, 'views/layouts'),
defaultLayout: 'main',
viewPath: path.join(__dirname, 'views')
}));
This should be a straightforward workaround. So not that critical to make the real fix quickly. I may have free time, not sure.
Related to this: https://github.com/nodejs/node/issues/1215
koa-hbs converts user given
viewPath
to an array if it's a string:Then in
getLayoutPath()
, iflayoutsPath
is not defined,this.viewPath
is given as a parameter topath.join
. Which in latest Node leads to:https://github.com/gilt/koa-hbs/blob/master/index.js#L219 line seems problematic. It doesn't do the right thing if the
viewPath
is an array even with node <6 I think. Older node versions return a comma separated list of paths. That will lead to file not found.