Skip to content

Commit

Permalink
Added res.render() status support back
Browse files Browse the repository at this point in the history
useful for error templates that display the status _and_
set the status code
  • Loading branch information
tj committed Mar 8, 2011
1 parent d4f4b66 commit d152e7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/view.js
Expand Up @@ -195,6 +195,9 @@ res.render = function(view, opts, fn, parent){
// merge render() .locals
if (opts && opts.locals) merge(options, opts.locals);

// status support
if (options.status) this.statusCode = options.status;

// Defaults
var self = this
, root = app.set('views') || process.cwd() + '/views'
Expand Down
7 changes: 7 additions & 0 deletions test/view.test.js
Expand Up @@ -182,6 +182,13 @@ module.exports = {
res.render('ferret', { layout: false, ferret: { name: 'Tobi' }});
});

app.get('/status', function(req, res){
res.render('hello.jade', { status: 500 });
});

assert.response(app,
{ url: '/status' },
{ status: 500 });
assert.response(app,
{ url: '/ferret' },
{ body: '<li class="ferret">Tobi</li>' });
Expand Down

0 comments on commit d152e7e

Please sign in to comment.