started flipping view extensions
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Aaron Heckmann · committed by Aaron Heckmann · parent 0849768 · Browse files · 6 files·+20 added−124 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+20 added−124 removed
- other:+20 added−124 removed
Provenance
- Commit
b9637c9- Tree
c57ac27- Author
Aaron Heckmann <aaron.heckmann@gmail.com>- Committer
Aaron Heckmann <aaron.heckmann@gmail.com>- Parent
0849768
6 files changed+20 added−124 removed
deleted:examples/chat/views/partials/message.haml.html-1 removed
1%li= messageNo newline at end of filedeleted:examples/chat/views/chat.haml.html-9 removed
123456789%h1 Chat%img.bubble{ src: '/public/images/bubble.png' }%ul#messages = this.partial('message.haml.html', { collection: messages })%form{ method: 'post' } %input{ type: 'hidden', name: '_method', value: 'put' } %input{ type: 'text', name: 'name', value: name || 'guest' } %input{ type: 'text', name: 'message' } %input{ type: 'submit', value: 'Send' }No newline at end of filedeleted:examples/chat/views/layout.haml.html-11 removed
1234567891011%html %head %title= title %script{ src: '/public/javascripts/jquery.js' } %script{ src: '/public/javascripts/app.js' } %link{ rel: 'stylesheet', href: '/style.css' } %body #wrapper= body #online Online: %strong= usersOnlineNo newline at end of filedeleted:examples/chat/views/style.sass.css-81 removed
1-body2- :font-family "Helvetica Neue", "Lucida Grande", "Arial"3- :font-size 13px4- :text-align center5- =text-stroke 1px rgba(255, 255, 255, 0.1)6- :color #5557- 8-h1, h29- :margin 010- :font-size 22px11- :color #34343412-h113- :text-shadow 1px 2px 2px #ddd14- :font-size 60px15- 16-img.bubble17- :position absolute18- :top -25px19- :left 120px20- 21-#wrapper22- :position relative23- :margin 100px auto24- :width 500px25- :text-align left26- 27-ul28- :margin 029- :padding 030- :max-height 300px31- :overflow-x hidden32- li33- :margin 5px 034- :padding 3px 8px35- :list-style none36- :border 1px solid #eee37- =border-radius 3px38- =border-radius 3px39- li:hover40- :cursor pointer41- :color #2E2E2E42-43-input[type=text]44- :padding 5px45- :border 1px solid #ddd46- :outline none47- =border-radius 2px48-input[type=text]:focus49- :border-color #00C3FF50-51-input[type=submit]52- =border-radius 2px53- =box-shadow 0 1px 2px #ddd54- :padding 6px 10px55- :border solid 1px #99956- :background -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ddd))57- :color #33358- :text-decoration none59- :cursor pointer60- :display inline-block61- :text-align center62- :text-shadow 0px 1px 1px #fff63- :line-height 164-input[type=submit]:hover65- :background -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#E6E4E4))66-input[type=submit]:active67- :background -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#c7c7c7))68-input[name=name]69- :width 80px70- 71-a72- :color #1ABFF173- =transition-property padding74- =transition-duration 0.15s75-a:hover76- :padding 0 5px77-a:hover:before78- :content 'visit: '79- 80-#online81- :font-size 12pxmodified:examples/chat/app.js+2 added-2 removed
22 unmodified lines2324252627272829303124 unmodified lines5657585960606162636415 unmodified lines22 unmodified lines
get('/chat', function(){ var self = this Session.store.length(function(err, len){ self.render('chat.haml.html', { self.render('chat.html.haml', { locals: { title: 'Chat', messages: messages, name: self.session.name,24 unmodified lines }, 100)})
get('/*.css', function(file){ this.render(file + '.sass.css', { layout: false }) this.render(file + '.css.sass', { layout: false })})
get('/error/view', function(){ this.render('does.not.exist')15 unmodified linesmodified:lib/express/plugins/view.js+18 added-20 removed
133 unmodified lines134 * @api public135 */136 137 render: function(view, options, callback) {138- var self = this,139- options = options || {},138+ var options = options || {},139 type = options.partial ? 'partials' : 'views',140 path = set(type) + '/' + view,142- engine = path.split('.').slice(-2)[0],143- ext = extname(path),141+ parts = view.split('.'),142+ engine = parts.last,143+ contentType = parts.slice(-2)[0],144 layout = options.layout === undefined ? 'layout' : options.layout145+ content = cache[type][path] || fs.readFileSync(path)146 options.context = options.context || this146- if (type === 'views') self.contentType(ext)147- function render(content) {148- content = (engines[engine] = engines[engine] || require(engine)).render(content, options)149- if (layout)150- self.render(layout + '.' + engine + ext, options.mergeDeep({151- layout: false,152- locals: { body: content }153- }), callback)154- else if (type === 'partials')155- return content156- else if (callback)157- callback.call(self, null, content)158- else159- self.halt(200, content)147+ content = (engines[engine] = engines[engine] || require(engine)).render(content, options)148+ if (type === 'views') this.contentType(contentType)149+ if (layout)150+ this.render([layout, contentType, engine].join('.'), options.mergeDeep({151+ layout: false,152+ locals: { body: content }153+ }), callback)154+ else if (type === 'partials')155+ return content156+ else if (callback)157+ callback.call(this, null, content)158+ else159+ this.halt(200, content)160- }161- return render(cache[type][path] || fs.readFileSync(path))160 }161 })162 }163 }2 unmodified lines