Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var ejsLayoutEngine = require('ejs-locals');
// Wait until express is ready, then configure the view engine
return sails.after('hook:http:loaded', function () {
sails.log.verbose('Overriding ejs engine config with ejslocals to implement layout support...');
sails.config.views.engine.fn = ejsLayoutEngine;
cb();
});
}
else if (engineName === 'handlebars') {
var exphbs = require('express-handlebars');
var handlebarsMajorVersion;
try {
handlebarsMajorVersion = semver.major(require('express-handlebars/node_modules/handlebars').VERSION);
} catch (e) {
try {
handlebarsMajorVersion = semver.major(require('handlebars').VERSION);
}
catch (e2) {
handlebarsVersion = null;
}
}
if (!handlebarsMajorVersion) {sails.log.warn('Could not determine Handlebars version; versions < 4.0.0 may introduce security risks (see https://snyk.io/test/npm/handlebars/3)');}
else if (handlebarsMajorVersion < 4) {
sails.log.warn('Using Handlebars v' + handlebarsMajorVersion + '.x; Versions < 4.0.0 may introduce security risks (see https://snyk.io/test/npm/handlebars/3).');
sails.log.warn('When an updated version becomes available, you should be able to install it by updating your copy of Sails with `npm update`.');}
return sails.after('hook:http:loaded', function() {
sails.log.verbose('Overriding handlebars engine with express-handlebars to implement layout support...');
var hbs = exphbs.create({
defaultLayout: path.join('..', (sails.config.views.layout + '.' + (sails.config.views.extension || 'handlebars')) || ''),