From 158c9eb59082b3b0d2f28ea7ebf66f2b7715e991 Mon Sep 17 00:00:00 2001 From: Harshit Date: Wed, 19 Nov 2025 13:08:57 +0530 Subject: [PATCH] fix: allow null options in app.render --- lib/application.js | 2 ++ test/app.render.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/application.js b/lib/application.js index cf6d78c741e..2231a0c75f3 100644 --- a/lib/application.js +++ b/lib/application.js @@ -530,6 +530,8 @@ app.render = function render(name, options, callback) { if (typeof options === 'function') { done = options; opts = {}; + } else if (options == null) { + opts = {}; } // merge options diff --git a/test/app.render.js b/test/app.render.js index ca15e761d35..bd65ce1035b 100644 --- a/test/app.render.js +++ b/test/app.render.js @@ -331,6 +331,24 @@ describe('app', function(){ }) }) + it('should accept null or undefined options', function (done) { + var app = createApp() + + app.set('views', path.join(__dirname, 'fixtures')) + app.locals.user = { name: 'tobi' } + + app.render('user.tmpl', null, function (err, str) { + if (err) return done(err); + assert.strictEqual(str, '

tobi

') + + app.render('user.tmpl', undefined, function (err2, str2) { + if (err2) return done(err2); + assert.strictEqual(str2, '

tobi

') + done() + }) + }) + }) + describe('caching', function(){ it('should cache with cache option', function(done){ var app = express();