Closed MarkCancellieri closed 9 years ago
Is this an issue only with the defaultLayout
file not supporting dots in the filename? Or do you have this issue with the view names you pass to res.render()
?
I see what's likely causing this issue: https://github.com/ericf/express-handlebars/blob/master/lib/express-handlebars.js#L318-320
Feel free to open a PR to adjust this.
I'm still somewhat of a newbie at programming (and with Git/GitHub), so bear with me.
I guess I have two issues then. I tried changing index_view_server.hbs
(which worked fine) to index.view.server.hbs
(and I changed the view names that are passed to res.render()
). It gave me the following error:
Error: Cannot find module 'server'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at new View (C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\node_modules\express\lib\view.js:50:49)
at EventEmitter.app.render (C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\node_modules\express\lib\application.js:509:12)
at ServerResponse.res.render (C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\node_modules\express\lib\response.js:904:7)
at getHomePage (C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\app_server\controllers\main.controller.server.js:7:7)
at Layer.handle [as handle_request] (C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\node_modules\express\lib\router\layer.js:82:5)
at next (C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\node_modules\express\lib\router\route.js:100:13)
The way this package works, and the way Express works, you'll need to always put the view's file extension (.hbs
) in the file paths if you want to use .
s in the file names.
So you'll need to do:
res.render('index.view.server.hbs);
And also use defaultLayout: 'main.view.server.hbs'
when configuring this package.
Oh, okay. Thanks for the help!
If I try to name my default layout to
main.view.server.hbs
, then I get the following error: Error: ENOENT, open 'C:\Users\Mark\Dropbox\WebstormProjects\NodeApp\app_server\views\layouts\main.view.server'If I instead name it
main-view-server.hbs
ormain_view_server.hbs
, then it works fine. In all three cases, I obviously changed thedefaultLayout
setting.Is there any way to get it to work using periods in the filename? I'm trying to maintain a consistent file-naming scheme. If not, it's not a huge issue, but it would be nice to be able to do it. :-)