Skip to content
Myr

unroll partial rendering for performance

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 3a42350 · Browse files · 1 file+17 added−11 removed
This commit

State

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

Diff stats

1 file+17 added−11 removed

  • other:+17 added−11 removed

1 file+17 added−11 removed

modified:lib/express/view.js+17 added-11 removed
61 unmodified lines
62 * @api public63 */6465http.ServerResponse.prototype.partial = function(view, options, locals, parent){66 var self = this;6768 // Inherit parent view extension when not present69 if (parent && !~view.indexOf('.')) {70 view += parent.extension;
24 unmodified lines
9596 // Deduce name from view path97 var name = options.as || Partial.resolveObjectName(view);9899 // Render partial100 function render(){101 if (options.object) {102 if ('string' == typeof name) {103 options[name] = options.object;104 } else if (name === global) {105 merge(options, options.object);106 } else {107 options.scope = options.object;108 }109 }110 return self.render(view, options);111 }112113 // Collection support114 var collection = options.collection;115 if (collection) {116 var len = collection.length
5 unmodified lines
122 options.firstInCollection = i === 0;123 options.indexInCollection = i;124 options.lastInCollection = i === len - 1;125 options.object = val;111 buf += this.partial(view, options);126 buf += render();127 }128 return buf;129 } else {115 if (options.object) {116 if ('string' == typeof name) {117 options[name] = options.object;118 } else if (name === global) {119 merge(options, options.object);120 } else {121 options.scope = options.object;122 }123 }124 return this.render(view, options);130 return render();131 }132};133134/**
125 unmodified lines