Skip to content
Myr

Added app level view options

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

via the "view options" setting

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 8d716fb · Browse files · 3 files+21 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

3 files+21 added−4 removed

  • tests:+15 added−2 removed
  • other:+6 added−2 removed

3 files+21 added−4 removed

modified:lib/express/view.js+6 added-2 removed
153 unmodified lines
154 * @api public155 */156157http.ServerResponse.prototype.render = function(view, options, fn){158 options = options || {};159 var defaultEngine = this.app.set('view engine');158 var options = options || {},159 viewOptions = this.app.set('view options'),160 defaultEngine = this.app.set('view engine');161162 // Mixin "view options"163 if (viewOptions) options.__proto__ = viewOptions;164165 // Support "view engine" setting166 if (view.indexOf('.') < 0 && defaultEngine) {167 view += '.' + defaultEngine;168 }
103 unmodified lines
added:test/fixtures/video.ejs+1 added
1<h1><?= title ?></h1>
modified:test/view.test.js+14 added-2 removed
374 unmodified lines
375 open: '{{',376 close: '}}'377 });378 379 379 app.get('/', function(req, res, next){380 res.render('user.ejs', {381 locals: {382 name: 'tj',
1 unmodified line
384 }385 });386 });387 388 app.get('/video', function(req, res, next){389 res.render('video.ejs', {390 open: '<?',391 close: '?>',392 locals: {393 title: 'keyboard cat'394 }395 });396 });397 398 assert.response(app,399 { url: '/' },391 { body: '<h1>tj</h1><p>tj@vision-media.ca</p>' });400 { body: '<h1>tj</h1>\n<p>tj@vision-media.ca</p>' });401 assert.response(app,402 { url: '/video' },403 { body: '<h1>keyboard cat</h1>' });404 }405};