Open wicaksana94 opened 4 years ago
@wicaksana94 you have to create folder layouts inside views and create file main.handlebars inside layout
why? because if you search on node_modules/express-handlebars/express-handlebars.js you can find these code :
var view; var viewsPath = options.settings && options.settings.views; if (viewsPath) { view = this._getTemplateName(path.relative(viewsPath, viewPath)); this.partialsDir = this.partialsDir || path.join(viewsPath, 'partials/'); this.layoutsDir = this.layoutsDir || path.join(viewsPath, 'layouts/'); }
and this code :
function ExpressHandlebars(config) { // Config properties with defaults. utils.assign(this, { handlebars: Handlebars, extname: '.handlebars', layoutsDir: undefined, // Default layouts directory is relative to
express settings.view+
layouts/ partialsDir: undefined, // Default partials directory is relative to
express settings.view+
partials/ defaultLayout: 'main', helpers: undefined, compilerOptions: undefined, }, config);
first, when i cloned this repo, i was faced the problems like you did, but you can use my way to solve it...
@wicaksana94 you have to create folder layouts inside views and create file main.handlebars inside layout
views\layouts\main.handlebars
why? because if you search on node_modules/express-handlebars/express-handlebars.js you can find these code :
var view; var viewsPath = options.settings && options.settings.views; if (viewsPath) { view = this._getTemplateName(path.relative(viewsPath, viewPath)); this.partialsDir = this.partialsDir || path.join(viewsPath, 'partials/'); this.layoutsDir = this.layoutsDir || path.join(viewsPath, 'layouts/'); }
and this code :
function ExpressHandlebars(config) { // Config properties with defaults. utils.assign(this, { handlebars: Handlebars, extname: '.handlebars', layoutsDir: undefined, // Default layouts directory is relative to
express settings.view+
layouts/partialsDir: undefined, // Default partials directory is relative to
express settings.view+
partials/defaultLayout: 'main', helpers: undefined, compilerOptions: undefined, }, config);
first, when i cloned this repo, i was faced the problems like you did, but you can use my way to solve it...
Okay @ivandi1980 , I'll do PR
Error: ENOENT: no such file or directory, open 'simple-express-handlebars-boilerplate\views\layouts\main.handlebars'
How I got this error :