frankxuzy / notebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

notebook

14/04/2018

issue found when changing the default directory of handlebar views folder

server.set('view engine', 'hbs')
server.set('views', path.join(__dirname, 'views'))
server.engine('hbs', hbs({
  extname: 'hbs',
  defaultLayout: 'main'
}))

There is an error message: Error: ENOENT: no such file or directory, open '/Users/frank/Desktop/EDAWorkspace/pp/colorful-life/views/layouts/main.hbs'

google and find the solution But this new change didn't update to npm.
so in node_modules we need to add below code into express-handlebars.js manually

     if (viewsPath) {
         view = this._getTemplateName(path.relative(viewsPath, viewPath));
+        this.partialsDir = path.join(viewsPath, 'partials/');
+        this.layoutsDir = path.join(viewsPath, 'layouts/');
     }

Problem solved.

About

License:MIT License