fix: crash when express views set to string

This commit is contained in:
harttle
2016-11-06 16:22:52 +08:00
parent e9ff3d916d
commit a82e50e1ab
5 changed files with 66 additions and 67 deletions
+7 -6
View File
@@ -102,13 +102,14 @@ var _engine = {
}
});
},
express: function(renderOption) {
renderOption = renderOption || {};
express: function(opts) {
opts = opts || {};
var self = this;
return function(filePath, options, callback) {
assert(_.isArray(this.root), 'illegal views root, are you using express.js?');
renderOption.root = this.root;
self.renderFile(filePath, options, renderOption)
return function(filePath, ctx, callback) {
assert(_.isArray(this.root) || _.isString(this.root),
'illegal views root, are you using express.js?');
opts.root = this.root;
self.renderFile(filePath, ctx, opts)
.then(html => callback(null, html))
.catch(e => callback(e));
};