Skip to content
Myr

Added res.render() status support back

Before adoption: this commit came in with the history the project adopted, so no landing records it.

useful for error templates that display the status _and_ set the status code

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent d4f4b66 · Browse files · 2 files+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−0 removed

  • tests:+7 added−0 removed
  • other:+3 added−0 removed

2 files+10 added−0 removed

modified:lib/view.js+3 added
193 unmodified lines
194195 // merge render() .locals196 if (opts && opts.locals) merge(options, opts.locals);197198 // status support199 if (options.status) this.statusCode = options.status;200201 // Defaults202 var self = this203 , root = app.set('views') || process.cwd() + '/views'204 , partial = options.renderPartial
105 unmodified lines
modified:test/view.test.js+7 added
180 unmodified lines
181 app.get('/ferret', function(req, res){182 res.render('ferret', { layout: false, ferret: { name: 'Tobi' }});183 });184185 app.get('/status', function(req, res){186 res.render('hello.jade', { status: 500 });187 });188189 assert.response(app,190 { url: '/status' },191 { status: 500 });192 assert.response(app,193 { url: '/ferret' },194 { body: '<li class="ferret">Tobi</li>' });195 assert.response(app,196 { url: '/' },
710 unmodified lines