Created
August 18, 2014 06:58
-
-
Save srivathsapv/5dcebf41d528b7979ea9 to your computer and use it in GitHub Desktop.
Specifying multiple views for Express 4.x
This file contains 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 enableMultipleViewFolders = function(express) { | |
var eView= express.get('view'); | |
var lookupProxy = eView.prototype.lookup; | |
eView.prototype.lookup = function (view) { | |
if (this.root instanceof Array) { | |
var opts = {}; | |
var matchedView = null, | |
roots = this.root; | |
for (var i=0; i<roots.length; i++) { | |
this.root = roots[i]; | |
matchedView = lookupProxy.call(this, view); | |
if (exists(matchedView)) break; | |
} | |
return matchedView; | |
} | |
return lookupProxy.call(eView, view) | |
}; | |
} | |
enableMultipleViewFolders(app); | |
app.set('views', [pathToView1, pathToView2]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment