Skip to content

Instantly share code, notes, and snippets.

@radiovisual
Last active September 25, 2015 15:39
Show Gist options
  • Save radiovisual/fb10ade6a3aa275dd627 to your computer and use it in GitHub Desktop.
Save radiovisual/fb10ade6a3aa275dd627 to your computer and use it in GitHub Desktop.
Add a rootpath value to your keystone templates
var path = require('path');
exports.assignRootPath = function(req, res, next) {
var locals = res.locals;
var rootPath = "";
req.path.split(path.sep).forEach(function(item){
if(item) {
rootPath += "../";
}
});
locals.rootPath = rootPath;
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment