ericf / express-handlebars

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

ENOENT: no such file or directory, open '...../views/pages/layouts/main.handlebars' #285

Closed jakubiszon closed 4 years ago

jakubiszon commented 4 years ago

Is having the layouts directory mandatory? Is having the main.handlebars file mandaotry? If so - the documentation does not state they MUST exist in order for the engine to work.

Here is what I have tried that resulted in the quoted error message:

...
app.set( 'views', __dirname + '/views/pages/' );
...
app.get('/', function( req, res ) { res.render( 'index' ) } );

The file '/views/pages/index.handlebars' does exist.

I realize it may be a noob problem but still it is either the module which doesn't support simplest cases or the documentation which fails to communicate what is required.

UziTech commented 4 years ago

All new development is on the repo express-handlebars/express-handlebars.

you can set the defaultLayout option to null if you do not want a layout.

jakubiszon commented 4 years ago

Thank you, that helped. I updated the readme file in the repo you mentioned to give better information on opting out from using layouts. I think this issue can be closed now.