Skip to content
Myr

Merge branch 'render-callback'

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 f088830, f7f7592 · Browse files · 3 files+25 added−1 removed
This commit

State

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

Diff stats

3 files+25 added−1 removed

  • tests:+19 added−0 removed
  • other:+6 added−1 removed

3 files+25 added−1 removed

modified:lib/express/view.js+6 added-1 removed
147 unmodified lines
148 * - `locals` Object containing local variables149 * - `debug` Output debugging information150 *151 * @param {String} view152 * @param {Object} options152 * @param {Object|Function} options or callback function153 * @param {Function} fn154 * @api public155 */156157http.ServerResponse.prototype.render = function(view, options, fn){158 // Support callback function as second arg159 if (typeof options === 'function') {160 fn = options, options = {};161 }162 163 var options = options || {},164 viewOptions = this.app.set('view options'),165 defaultEngine = this.app.set('view engine');166
112 unmodified lines
added:test/fixtures/hello.jade+1 added
1p :(
modified:test/view.test.js+18 added
25 unmodified lines
26 });27 app.get('/haml', function(req, res){28 res.render('hello.haml', { layout: false });29 });30 app.get('/callback/layout/no-options', function(req, res){31 res.render('hello.jade', function(err, str){32 assert.ok(!err);33 res.send(str.replace(':(', ':)'));34 });35 });36 app.get('/callback/layout', function(req, res){37 res.render('hello.jade', {}, function(err, str){38 assert.ok(!err);39 res.send(str.replace(':(', ':)'));40 });41 });42 app.get('/callback', function(req, res){43 res.render('hello.haml', { layout: false }, function(err, str){44 assert.ok(!err);45 res.send(str.replace('Hello World', ':)'));
31 unmodified lines
77 assert.response(app,78 { url: '/callback' },79 { body: '\n<p>:)</p>' });80 assert.response(app,81 { url: '/callback/layout' },82 { body: '<html><body><p>:)</p></body></html>' });83 assert.response(app,84 { url: '/callback/layout/no-options' },85 { body: '<html><body><p>:)</p></body></html>' });86 assert.response(app,87 { url: '/error' },88 { body: 'doesNotExist' });89 assert.response(app,90 { url: '/invalid' },
354 unmodified lines