Skip to content

Commit 158c9eb

Browse files
committed
fix: allow null options in app.render
1 parent 2551a7d commit 158c9eb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/application.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ app.render = function render(name, options, callback) {
530530
if (typeof options === 'function') {
531531
done = options;
532532
opts = {};
533+
} else if (options == null) {
534+
opts = {};
533535
}
534536

535537
// merge options

test/app.render.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,24 @@ describe('app', function(){
331331
})
332332
})
333333

334+
it('should accept null or undefined options', function (done) {
335+
var app = createApp()
336+
337+
app.set('views', path.join(__dirname, 'fixtures'))
338+
app.locals.user = { name: 'tobi' }
339+
340+
app.render('user.tmpl', null, function (err, str) {
341+
if (err) return done(err);
342+
assert.strictEqual(str, '<p>tobi</p>')
343+
344+
app.render('user.tmpl', undefined, function (err2, str2) {
345+
if (err2) return done(err2);
346+
assert.strictEqual(str2, '<p>tobi</p>')
347+
done()
348+
})
349+
})
350+
})
351+
334352
describe('caching', function(){
335353
it('should cache with cache option', function(done){
336354
var app = express();

0 commit comments

Comments
 (0)