Skip to content
Myr

Merge branch 'feature/view-layout-control'

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 f6e9fb1, 371d66b · Browse files · 9 files+71 added−0 removed
This commit

State

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

Diff stats

9 files+71 added−0 removed

  • tests:+16 added−0 removed
  • other:+55 added−0 removed

9 files+71 added−0 removed

added:examples/layout-control/views/layouts/alternate.ejs+6 added
1<html>2 <body>3 <h1>Alternate Layout</h1>4 <%- body %>5 </body>6</html>
added:examples/layout-control/views/layouts/default.ejs+6 added
1<html>2 <body>3 <h1>Default Layout</h1>4 <%- body %>5 </body>6</html>
added:examples/layout-control/views/pages/alternate.ejs+2 added
1<% layout('layouts/alternate') %>2<h1>Page</h1>
added:examples/layout-control/views/pages/default.ejs+1 added
1<h1>Page</h1>
added:examples/layout-control/app.js+35 added
modified:lib/view.js+5 added
344 unmodified lines
345 view.fn = engine.compile(view.contents, options)346 if (cacheViews) cache[orig.view] = view;347 }348349 // layout helper350 options.layout = function(path){351 layout = path;352 };353354 // render355 var str = view.fn.call(options.scope, options);356357 // layout expected
35 unmodified lines
added:test/fixtures/layouts/alternate.jade+1 added
1#alternate!= body
added:test/fixtures/layout-switch.jade+2 added
1- layout('layouts/alternate')2h1 My Page
modified:test/view.test.js+13 added
285 unmodified lines
286 { url: '/' },287 { body: '<cool><p>Welcome</p></cool>' });288 },289 290 'test #render() view layout control': function(){291 var app = create();292 app.set('view engine', 'jade');293 294 app.get('/', function(req, res){295 res.render('layout-switch');296 });297 298 assert.response(app,299 { url: '/' },300 { body: '<div id="alternate"><h1>My Page</h1></div>' });301 },302 303 'test #render() "view engine" with periods in dirname': function(){304 var app = create();305 app.set('view engine', 'jade');306
763 unmodified lines