add render method for controller, alias of display

This commit is contained in:
lichengyin 2016-01-05 09:05:46 +08:00
parent eb81d7e78e
commit fef8765325
2 changed files with 21 additions and 0 deletions

View File

@ -234,6 +234,16 @@ export default class extends think.http.base {
this._baseAssign();
return this.view().display(templateFile, charset, contentType);
}
/**
* alias of display
* @param {String} templateFile [template filepath]
* @param {String} charset [content encoding]
* @param {String} contentType [content type]
* @return {Promise} []
*/
render(templateFile, charset, contentType){
return this.display(templateFile, charset, contentType);
}
/**
* output with jsonp
* @param {Object} data [output data]

View File

@ -423,6 +423,17 @@ describe('controller/base.js', function(){
done();
})
})
it('render', function(done){
muk(think, 'log', function(){})
getInstance({
}).then(function(instance){
return instance.render(__filename)
}).catch(function(err){
assert.equal(think.isPrevent(err), true);
muk.restore();
done();
})
})
it('download', function(done){
getInstance({
header: function(type, value){