Changements dans les modules (nouvelle version Express, mysql, ..)
This commit is contained in:
38
node_modules/express/lib/view.js
generated
vendored
38
node_modules/express/lib/view.js
generated
vendored
@@ -16,6 +16,7 @@
|
||||
var debug = require('debug')('express:view');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
@@ -74,17 +75,7 @@ function View(name, options) {
|
||||
|
||||
if (!opts.engines[this.ext]) {
|
||||
// load engine
|
||||
var mod = this.ext.slice(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
|
||||
opts.engines[this.ext] = require(this.ext.substr(1)).__express;
|
||||
}
|
||||
|
||||
// store loaded engine
|
||||
@@ -131,8 +122,31 @@ View.prototype.lookup = function lookup(name) {
|
||||
*/
|
||||
|
||||
View.prototype.render = function render(options, callback) {
|
||||
var sync = true;
|
||||
|
||||
debug('render "%s"', this.path);
|
||||
this.engine(this.path, options, callback);
|
||||
|
||||
// render, normalizing sync callbacks
|
||||
this.engine(this.path, options, function onRender() {
|
||||
if (!sync) {
|
||||
return callback.apply(this, arguments);
|
||||
}
|
||||
|
||||
// copy arguments
|
||||
var args = new Array(arguments.length);
|
||||
var cntx = this;
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
|
||||
// force callback to be async
|
||||
return process.nextTick(function renderTick() {
|
||||
return callback.apply(cntx, args);
|
||||
});
|
||||
});
|
||||
|
||||
sync = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user