Skip to content
Myr

Added support for passing of layout name without extension

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

Utilizes the child view ext

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 687c2f0 · Browse files · 4 files+13 added−2 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+13 added−2 removed

  • tests:+8 added−2 removed
  • other:+5 added−0 removed

4 files+13 added−2 removed

modified:lib/express/view.js+5 added
233 unmodified lines
234 layout = layout === true235 ? 'layout' + ext236 : layout;237238 // Allow layout name without extension239 if (typeof layout === 'string' && layout.indexOf('.') < 0) {240 layout += ext;241 }242243 // Normalize "context" to "scope"244 options.scope = options.scope || options.context;245246 // Auto-cache in production
71 unmodified lines
added:test/fixtures/cool-layout.jade+1 added
1cool!= body
deleted:test/fixtures/cool.layout.jade-1 removed
1cool!= body
modified:test/view.test.js+7 added-1 removed
90 unmodified lines
91 var app = express.createServer();92 app.set('views', __dirname + '/fixtures');9394 app.get('/', function(req, res){95 res.render('index.jade', { layout: 'cool.layout.jade' });95 res.render('index.jade', { layout: 'cool-layout.jade' });96 });97 app.get('/no-ext', function(req, res){98 res.render('index.jade', { layout: 'cool-layout' });99 });100101 assert.response(app,102 { url: '/' },103 { body: '<cool><p>Welcome</p></cool>' });104 assert.response(app,105 { url: '/no-ext' },106 { body: '<cool><p>Welcome</p></cool>' });107 },108 109 'test #partial()': function(assert){110 var app = express.createServer();
136 unmodified lines