Created
March 13, 2013 05:29
-
-
Save mytharcher/5149597 to your computer and use it in GitHub Desktop.
Partials path config for Hogan(Mustache) in Express.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.set('partials', require('./lib/partials')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var approot = process.env.PWD; | |
var path = require('path'); | |
var glob = require('glob'); | |
var config = require(approot + '/config'); | |
var partialsPath = path.join(approot, config.path.views, config.path.partials); | |
var RE = new RegExp('^' + partialsPath + '/|\\.' + config.viewExt + '$', 'g'); | |
glob.sync(partialsPath + '/**/*.' + config.viewExt).forEach(function (file) { | |
var partPath = file.replace(RE, ''); | |
exports[partPath] = file; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist was deprecated. Please turn to MustLayout instead.