Skip to content

Commit

Permalink
Added some comments, updated "view engine not found" message
Browse files Browse the repository at this point in the history
  • Loading branch information
sgress454 committed May 20, 2015
1 parent 78b5e2d commit 066fa54
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/hooks/views/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,22 @@ module.exports = function configure ( sails ) {
);

try {
//fn = consolidate(appDependenciesPath)[engineName];

// Try to looad the view engine
fn = getEngine(appDependenciesPath,engineName);


// If the engine doesn't export a function, it's not consolidate-compatible
if ( !_.isFunction(fn) ) {
sails.log.error(util.format('Invalid view engine (%s)-- are you sure it supports `consolidate`?', engineName));
throw new Error();
}
}

// If the engine can't be loaded, we can't continue
catch (e) {
sails.log.error('Your configured server-side view engine (' + engineName + ') could not be found.');
sails.log.error('Usually, this just means you need to install a dependency.');
sails.log.error('To install ' + engineName + ', run: `npm install ' + engineName + ' --save`');
sails.log.error('To install ' + engineName + ', try running: `npm install ' + engineName + ' --save`');
sails.log.error('Otherwise, please change your `engine` configuration in config/views.js.');
throw e;
}
Expand Down Expand Up @@ -112,6 +114,8 @@ module.exports = function configure ( sails ) {
}
};

// Load a view engine either from the Consolidate cache or from a module installed
// locally to the Sails app.
function getEngine(appDependenciesPath,engineName) {
var fn = consolidate[engineName];

Expand Down

0 comments on commit 066fa54

Please sign in to comment.