ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 383 forks source link

Can't find partials #66

Closed ghost closed 10 years ago

ghost commented 10 years ago

I have changed the partialsDir to be ./server/views/partials, however it doesn't seem to work at all, as none of the partials are found. I have the following code in my server.js file:

app.engine('html', Handlebars({
    extname: 'html', 
    defaultLayout: 'main.html', 
    layoutsDir: './server/views/layouts/',
    partialsDir: './server/views/partials/'
}));

The layouts, however, can be found. Has anyone else experienced this issue as well?

ghost commented 10 years ago

I solved it myself with the following code:

// Configure Handlebars
var hbs = Handlebars.create({
    defaultLayout: 'main',
    extname: '.html',

    layoutsDir: __dirname + '/server/views/layouts/',
    partialsDir: __dirname + '/server/views/partials/'
});

// Views folder and engine
app.set('views', __dirname + '/server/views/');
app.set('view engine', 'hbs');
app.engine('html', hbs.engine);