Merge branch 'features/render-status'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parents 74a0673, bb2e24e · Browse files · 4 files·+46 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+46 added−4 removed
- tests:+36 added−0 removed
- other:+10 added−4 removed
Provenance
- Commit
57609c8- Tree
897858f- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent 1
74a0673- Parent 2
bb2e24e
4 files changed+46 added−4 removed
modified:docs/guide.md+2 added
509 unmodified lines510 511 - _context|scope_ Template evaluation context (_this_)512 - _locals_ Object containing local variables513 - _debug_ Output debugging information514+ - _status_ Response status code, defaults to 200515+ - _headers_ Response headers object516 517 ### res.partial(view[, options])518 519 Render _view_ partial with the given _options_. This method is always available200 unmodified linesmodified:examples/pages/app.js+5 added-3 removed
51 unmodified lines5253545556575859606 unmodified lines67686970717071727273747576777814 unmodified lines51 unmodified lines
app.error(function(err, req, res, next){ if (err instanceof NotFound) { res.render('404.jade', { status: 404, locals: { error: err } });6 unmodified lines// this demo, however you can choose whatever you like
app.error(function(err, req, res){ res.render('500.jade', { status: 500, locals: { error: err } locals: { error: err } });});
// Routes14 unmodified linesmodified:lib/express/view.js+3 added-1 removed
168 unmodified lines169 *170 * - `context|scope` Template evaluation context (`this`)171 * - `locals` Object containing local variables172 * - `debug` Output debugging information173+ * - `status` Response status code, defaults to 200174+ * - `headers` Response headers object175 *176 * @param {String} view177 * @param {Object|Function} options or callback function178 * @param {Function} fn117 unmodified lines296 return str;297 } else if (fn) {298 fn(null, str);299 } else {298- self.send(str);300+ self.send(str, options.headers, options.status);301 }302 };modified:test/view.test.js+36 added
206 unmodified lines207 { url: '/custom' },208 { body: '<p>2</p>'});209 },210 211+ 'test #render() status': function(assert){212+ var app = create();213+ 214+ app.get('/', function(req, res){215+ res.render('hello.jade', {216+ layout: false,217+ status: 404218+ });219+ });220+ 221+ assert.response(app,222+ { url: '/' },223+ { body: '<p>:(</p>', status: 404 });224+ },225+ 226+ 'test #render() headers': function(assert){227+ var app = create();228+ 229+ app.get('/', function(req, res){230+ res.render('hello.jade', {231+ layout: false,232+ status: 500,233+ headers: {234+ 'X-Foo': 'bar'235+ }236+ });237+ });238+ 239+ assert.response(app,240+ { url: '/' },241+ { body: '<p>:(</p>', status: 500, headers: {242+ 'X-Foo': 'bar',243+ 'Content-Type': 'text/html; charset=utf-8'244+ }});245+ },246+ 247 'test #render() view helpers': function(assert){248 var app = create();249 250 app.helpers({ 244 unmodified lines