Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading sails to 0.12 breaks handlebars #3559

Closed
sebastiankruk opened this issue Feb 9, 2016 · 4 comments
Closed

Upgrading sails to 0.12 breaks handlebars #3559

sebastiankruk opened this issue Feb 9, 2016 · 4 comments

Comments

@sebastiankruk
Copy link

I wanted to get rid of the sails 0.11.x dependency on the express-handlebars 2.x.x which depended on handlebars < 4.

warn: Using Handlebars v3.x; Versions < 4.0.0 may introduce security risks (see https://snyk.io/test/npm/handlebars/3).
warn: When an updated version becomes available, you should be able to install it by updating your copy of Sails with npm update.

Apparently sails 0.12 does the trick, but it also breaks express-handlebars. I have the same problems as in #3232. When I upgrade to express-handlebars 3.0.0 and sails 0.12, I'm getting:

$PATH/node_modules/express-handlebars/lib/express-handlebars.js:38
    if (this.extname.charAt(0) !== '.') {
                    ^

TypeError: Cannot read property 'charAt' of undefined
    at new ExpressHandlebars ($PATH/node_modules/express-handlebars/lib/express-handlebars.js:38:21)
    at Function.create ($PATH/node_modules/express-handlebars/index.js:22:12)
    at layoutshim ($PATH/node_modules/sails/lib/hooks/views/layoutshim.js:36:26)
    at Hook.initialize ($PATH/node_modules/sails/lib/hooks/views/index.js:70:7)
    at Hook.wrapper [as initialize] ($PATH/node_modules/lodash/index.js:3095:19)
    at $PATH/node_modules/sails/lib/hooks/index.js:73:14
    at $PATH/node_modules/sails/node_modules/async/lib/async.js:52:16
    at $PATH/node_modules/sails/node_modules/async/lib/async.js:548:17
    at $PATH/node_modules/sails/node_modules/async/lib/async.js:542:17
    at _arrayEach ($PATH/node_modules/sails/node_modules/async/lib/async.js:85:13)
    at Immediate.taskComplete ($PATH/node_modules/sails/node_modules/async/lib/async.js:541:13)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

@olivierl
Copy link

olivierl commented Feb 9, 2016

+1

@sgress454
Copy link
Member

Try adding this to your config/views.js file:

extension: 'handlebars'

I'll take a look at why it's not working automatically.

@sebastiankruk
Copy link
Author

It works! Thanks :)

@sgress454
Copy link
Member

0.12.1 has been released with this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants