diff --git a/lib/express/view.js b/lib/express/view.js index e814997b95..681de1b995 100644 --- a/lib/express/view.js +++ b/lib/express/view.js @@ -149,12 +149,17 @@ http.ServerResponse.prototype.partial = function(view, options, ext){ * - `debug` Output debugging information * * @param {String} view - * @param {Object} options + * @param {Object|Function} options or callback function * @param {Function} fn * @api public */ http.ServerResponse.prototype.render = function(view, options, fn){ + // Support callback function as second arg + if (typeof options === 'function') { + fn = options, options = {}; + } + var options = options || {}, viewOptions = this.app.set('view options'), defaultEngine = this.app.set('view engine'); diff --git a/test/view.test.js b/test/view.test.js index ea2b3008e3..edbc932558 100644 --- a/test/view.test.js +++ b/test/view.test.js @@ -27,6 +27,12 @@ module.exports = { app.get('/haml', function(req, res){ res.render('hello.haml', { layout: false }); }); + app.get('/callback/layout/no-options', function(req, res){ + res.render('hello.jade', function(err, str){ + assert.ok(!err); + res.send(str.replace(':(', ':)')); + }); + }); app.get('/callback/layout', function(req, res){ res.render('hello.jade', {}, function(err, str){ assert.ok(!err); @@ -74,6 +80,9 @@ module.exports = { assert.response(app, { url: '/callback/layout' }, { body: '

:)

' }); + assert.response(app, + { url: '/callback/layout/no-options' }, + { body: '

:)

' }); assert.response(app, { url: '/error' }, { body: 'doesNotExist' });