Skip to content
Myr

Removed partial() / render() status and header options

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 · parent 51e9644 · Browse files · 2 files+3 added−45 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+3 added−45 removed

  • tests:+1 added−41 removed
  • other:+2 added−4 removed

2 files+3 added−45 removed

modified:lib/view.js+2 added-4 removed
148 unmodified lines
149 parent.extension = '.' + app.set('view engine');150 }151152 var str = renderPartial(this, view, options, null, parent);153 this.send(str, options.headers, options.status);153 this.send(str);154};155156/**157 * Render `view` with the given `options` and optional callback `fn`.
3 unmodified lines
161 * Options:162 * 163 * - `scope` Template evaluation context (the value of `this`)164 * - `debug` Output debugging information165 * - `status` Response status code, defaults to 200166 * - `headers` Response headers object165 *166 * @param {String} view167 * @param {Object|Function} options or callback function168 * @param {Function} fn
121 unmodified lines
290 return str;291 } else if (fn) {292 fn(null, str);293 } else {296 this.send(str, options.headers, options.status);294 this.send(str);295 }296};
modified:test/view.test.js+1 added-41 removed
334 unmodified lines
335 { url: '/custom' },336 { body: '<p>2</p>'});337 },338 339 'test #render() status': function(){340 var app = create();341 342 app.get('/', function(req, res){343 res.render('hello.jade', {344 layout: false,345 status: 404346 });347 });348 349 assert.response(app,350 { url: '/' },351 { body: '<p>:(</p>', status: 404 });352 },353 354 'test #render() headers': function(){355 var app = create();356 357 app.get('/', function(req, res){358 res.render('hello.jade', {359 layout: false,360 status: 500,361 headers: {362 'X-Foo': 'bar'363 }364 });365 });366 367 assert.response(app,368 { url: '/' },369 { body: '<p>:(</p>', status: 500, headers: {370 'X-Foo': 'bar',371 'Content-Type': 'text/html'372 }});373 },374 339 'test #render() view helpers': function(beforeExit){340 var app = create()341 , calls = 0;342
182 unmodified lines
525 app.get('/person-this', function(req, res){526 res.partial('person.jade', {527 object: { name: 'tj' },528 locals: { label: 'User:' },565 headers: { 'Content-Type': 'text/html; utf-8' },566 status: 500,529 as: this530 }); 531 });532 533 // Non-collection as: this534 assert.response(app,535 { url: '/person-this' },574 { body: '<p>User: tj</p>'575 , status: 500576 , headers: { 'Content-Type': 'text/html; utf-8' }});536 { body: '<p>User: tj</p>' });537538 // No options539 app.get('/nothing', function(req, res){540 res.partial('hello.ejs');
353 unmodified lines