Closed jacob-faber closed 8 years ago
@camabeh - path.join(__dirname, 'views'))
searches for server/views/<your-file-here>
. But the views are not inside server
folder. Update the path of views to use the correct path. app.set('views', __dirname + '/../views');
@swarajgiri I don't get it. I think it should respect app.locals.settings.views
and set layouts/
and partials/
relative to new views path. It looked in project's root folder for views/partials
and views/layouts
Here I fixed it. https://github.com/ericf/express-handlebars/pull/148
@camabeh - I have exactly the same issue. I modified (temporary) the code in the library according to your PR changes and confirm that it solves the problem. Until your PR is merged I choose to set
layoutsDir
and partialsDir
in engine factory:
app.set('views', config.root + '/server/views');
var exphbs = require('express-handlebars');
app.engine('.hbs', exphbs({
defaultLayout: 'main',
extname: '.hbs',
layoutsDir:'server/views/layouts',
partialsDir:'server/views/partials'
}));
app.set('view engine', '.hbs');
I have a problem: "Error: The partial header could not be found....."
does anyone know how to solve it?
Thanks Bro for this!!
Hello, I am unable to set default
views
directory.OS: Ubuntu 15.04 Node: 4.0.0
I am in app directory (...). When running
node server/server.js
, it ignoresapp.set('views', path.join(__dirname, 'views'));
fromserver.js
and tries to load.../views/layouts/main.handlebars
instead.../server/views/layouts/main.handlebars
server.js
EDIT: it works when i am in (
.../server/
directory) andnode server.js
, it is wierd, becouse it should get right path fromapp.locals.setting.views
variable.