Render() failed when given a directory and using non-HTML extension
gnituy18 opened this issue · 5 comments
gnituy18 commented
I use pug
as my default extension for my views.
And I structure my views
dir like this:
views/dirA/index.pug
views/dirA/_include.pug
views/dirB/index.pug
app.use(views(__dirname + '/views', {'extension': 'pug'}))
app.use(async function (ctx) {
await ctx.render('dirA')
})
I want to render dirA/index.pug
just by passing dirA
, but I got a error like this:
Error: ENOENT: no such file or directory, open '/blah/blah/blah/app/views/dirA/dirA/index.pug'
at Object.fs.openSync (fs.js:582:18)
........
........
........
at /blah/blah/blah/app/node_modules/koa-views/lib/index.js:53:20
Without the extension, everything works fine.
So when I go further... I think that
// koa-views/src/index.js:64
abs: join(abs, dirname(rel), rel),
is what causes .../views/dirA/dirA/index.pug
got 2 dirA
// koa-views/src/index.js:46
return render(resolve(paths.abs, paths.rel), state)
int64ago commented
Hi, do you use the latest version ?
gnituy18 commented
Yes. I'm using 6.0.0
int64ago commented