Merge branch 'integration'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parents 15beb81, 42b28d5 · Browse files · 5 files·+23 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+23 added−7 removed
- tests:+14 added−3 removed
- other:+9 added−4 removed
Provenance
- Commit
289487c- Tree
16ede61- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent 1
15beb81- Parent 2
42b28d5
5 files changed+23 added−7 removed
modified:lib/express/plugins/view.js+9 added-4 removed
148 unmodified linesExpand all1491501511521531531541551561571581591601611621611621631641651661671681691701661711721731741757 unmodified lines148 unmodified linesExpand all path = set(type) + '/' + view, parts = view.split('.'), engine = parts.last, contentType = parts.slice(-2)[0], layout = options.layout === undefined ? 'layout' : options.layout layout = options.layout === undefined ? 'layout' : options.layout options.filename = path if (set('cache view contents')) options.cache = true var content = cache[type][path] || fs.readFileSync(path) options.context = options.context || this content = (engines[engine] = engines[engine] || require(engine)).render(content, options) if (type === 'views') this.contentType(contentType) if (layout) this.render([layout, contentType, engine].join('.'), Object.mergeDeep(options, { if (layout) { layout = layout.indexOf('.') !== -1 ? layout : [layout, contentType, engine].join('.') this.render(layout, Object.mergeDeep(options, { layout: false, locals: { body: content } }), callback) else if (type === 'partials') } else if (type === 'partials') return content else if (callback) callback.call(this, null, content) else7 unmodified linesadded:spec/fixtures/layout-user.html.haml+2 added
1+%title= "Viewing " + name2+%body!= bodyadded:spec/fixtures/layout.html.ejs+1 added
1+<p><%= body %></p>deleted:spec/fixtures/layout.user.html.haml-2 removed
1-%title= "Viewing " + name2-%body!= bodymodified:spec/spec.plugins.view.js+11 added-1 removed
147 unmodified lines148 get('/').body.should.include '<h2>Hello'149 end150 end151 152+ describe 'given a full layout name'153+ it 'should render a layout of a different engine'154+ get('/', function(){155+ this.render('hello.html.haml', { layout: 'layout.html.ejs' })156+ })157+ get('/').body.should.include '<h2>Hello'158+ get('/').body.should.include '<p>'159+ end160+ end161+ 162 describe 'when layout: false'163 it 'should render the view only'164 get('/', function(){165 this.render('hello.html.haml', { layout: false })28 unmodified lines194 195 it 'should have direct access to locals within the layout'196 get('/user', function(){197 this.render('user.html.haml', {188- layout: 'layout.user',198+ layout: 'layout-user',199 locals: {200 name: 'tj',201 email: 'tj@vision-media.ca'202 }26 unmodified lines