How to use the express-handlebars/node_modules/handlebars.VERSION function in express-handlebars

To help you get started, weā€™ve selected a few express-handlebars examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github balderdashy / sails / lib / hooks / views / layoutshim.js View on Github external
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')) || ''),

express-handlebars

A Handlebars view engine for Express which doesn't suck.

BSD-3-Clause
Latest version published 10 months ago

Package Health Score

79 / 100
Full package analysis