Skip to content
Myr

Fixed res.render() callback when a layout is used [thanks guillermo]

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 868e4c4 · Browse files · 2 files+12 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

2 files+12 added−4 removed

  • tests:+11 added−3 removed
  • other:+1 added−1 removed

2 files+12 added−4 removed

modified:lib/express/view.js+1 added-1 removed
251 unmodified lines
252 // Layout support253 if (layout) {254 options.layout = false;255 options.locals.body = str;256 self.render(layout, options);256 self.render(layout, options, fn);257 } else if (partial) {258 return str;259 } else if (fn) {260 fn(null, str);
4 unmodified lines
modified:test/view.test.js+11 added-3 removed
97 unmodified lines
98 { url: '/' },99 { body: '<html><body><p>Welcome</p></body></html>' });100 },101 102 'test #render() specific layout': function(assert){103 var app = create();102 'test #render() specific layout': function(assert, beforeExit){103 var app = create(),104 called;105106 app.get('/', function(req, res){106 res.render('index.jade', { layout: 'cool-layout.jade' });107 res.render('index.jade', { layout: 'cool-layout.jade' }, function(err, html){108 called = true;109 res.send(html);110 });111 });112 app.get('/no-ext', function(req, res){113 res.render('index.jade', { layout: 'cool-layout' });114 });
15 unmodified lines
130 { body: '<foo></foo>' });131 assert.response(app,132 { url: '/absolute' },133 { body: '<foo></foo>' });134135 beforeExit(function(){136 assert.ok(called, 'Layout callback never called'); 137 });138 },139 140 'test #render() specific layout "view engine"': function(assert){141 var app = create();
210 unmodified lines