Actually, in issue #4593, I provided Express the imported view engine instance.
I registered it as "Eta" (".Eta" internally), and Express did not use it for search.eta (because it was only looking for the ".eta" one), triggering the undesired automatic require.
app.engine("Eta", Eta.renderFile);
console.log(app.engines); // { '.Eta': [Function: renderFile] }
app.set("view engine", "Eta");
function View(name, options) {
var opts = options || {};
this.defaultEngine = opts.defaultEngine;
this.ext = extname(name);
console.info("EXPRESS", [name, extname(name)]); // EXPRESS [ 'search.eta', '.eta' ]
this.name = name;
this.root = opts.root;
Maybe it should normalize the ext to a single case?
|
app.engine = function engine(ext, fn) { |
|
if (typeof fn !== 'function') { |
|
throw new Error('callback function required'); |
|
} |
|
|
|
// get file extension |
|
var extension = ext[0] !== '.' |
|
? '.' + ext |
|
: ext; |
|
|
|
// store engine |
|
this.engines[extension] = fn; |
|
|
|
return this; |
|
}; |
|
function View(name, options) { |
|
var opts = options || {}; |
|
|
|
this.defaultEngine = opts.defaultEngine; |
|
this.ext = extname(name); |
|
this.name = name; |
|
this.root = opts.root; |
|
|
|
if (!this.ext && !this.defaultEngine) { |
|
throw new Error('No default engine was specified and no extension was provided.'); |
|
} |
|
|
|
var fileName = name; |
|
|
|
if (!this.ext) { |
|
// get extension from default engine name |
|
this.ext = this.defaultEngine[0] !== '.' |
|
? '.' + this.defaultEngine |
|
: this.defaultEngine; |
|
|
|
fileName += this.ext; |
|
} |
|
|
|
if (!opts.engines[this.ext]) { |
|
// load engine |
|
var mod = this.ext.substr(1) |
|
debug('require "%s"', mod) |
|
|
|
// default engine export |
|
var fn = require(mod).__express |
|
|
|
if (typeof fn !== 'function') { |
|
throw new Error('Module "' + mod + '" does not provide a view engine.') |
|
} |
|
|
|
opts.engines[this.ext] = fn |
|
} |
Actually, in issue #4593, I provided Express the
imported view engine instance.I registered it as
"Eta"(".Eta"internally), and Express did not use it forsearch.eta(because it was only looking for the".eta"one), triggering the undesired automaticrequire.Maybe it should normalize the
extto a single case?express/lib/application.js
Lines 293 to 307 in 5c4f3e7
express/lib/view.js
Lines 52 to 88 in 5c4f3e7