Backend half
This commit is contained in:
+3
-26
@@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
var debug = require('debug')('express:view');
|
||||
var path = require('node:path');
|
||||
var fs = require('node:fs');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
@@ -131,31 +131,8 @@ View.prototype.lookup = function lookup(name) {
|
||||
*/
|
||||
|
||||
View.prototype.render = function render(options, callback) {
|
||||
var sync = true;
|
||||
|
||||
debug('render "%s"', this.path);
|
||||
|
||||
// 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;
|
||||
this.engine(this.path, options, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user