Skip to content
Myr

Partials without extensions use the same extension as the parent view

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 c02a2ba · Browse files · 2 files+12 added−9 removed
This commit

State

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

Diff stats

2 files+12 added−9 removed

  • tests:+1 added−1 removed
  • other:+11 added−8 removed

2 files+12 added−9 removed

modified:lib/express/view.js+11 added-8 removed
59 unmodified lines
60 * @return {String}61 * @api public62 */6364http.ServerResponse.prototype.partial = function(view, options){64http.ServerResponse.prototype.partial = function(view, options, ext){65 if (ext && view.indexOf('.') < 0) {66 view += ext;67 }68 if (options instanceof Array) {69 options = { collection: options };70 }71 options = options || {};
62 unmodified lines
134 if (this.app.set('env') === 'production') {135 options.cache = true;136 }137135 // Always expose partial() as a local136 options.locals = options.locals || {};137 options.locals.partial = function(){138 return self.partial.apply(self, arguments);139 };140138 // Partials support139 if (options.partial) {140 root += '/partials';141 }
9 unmodified lines
151 });152 self.end(str);153 }154 158 // Pass filename to the engine155 // Pass filename to the engine and view156 options.locals = options.locals || {};157 options.locals.__filename = options.filename = path;158159 // Always expose partial() as a local160 options.locals.partial = function(view, options){161 return self.partial.call(self, view, options, ext);162 };163164 function error(err) {165 if (fn) {166 fn(err);167 } else {
34 unmodified lines
modified:test/fixtures/movies.jade+1 added-1 removed
1ul!= partial('movie.jade', movies)1ul!= partial('movie', movies)