@@ -47,7 +47,10 @@ exports.register = View.register;
4747 */
4848
4949exports . compile = function ( view , cache , cid , options ) {
50- if ( cache && cid && cache [ cid ] ) return cache [ cid ] ;
50+ if ( cache && cid && cache [ cid ] ) {
51+ options . filename = cache [ cid ] . path ;
52+ return cache [ cid ] ;
53+ }
5154
5255 // lookup
5356 view = exports . lookup ( view , options ) ;
@@ -58,13 +61,13 @@ exports.compile = function(view, cache, cid, options){
5861 var err = new Error ( 'failed to locate view "' + view . original . view + '"' ) ;
5962 err . view = view . original ;
6063 throw err ;
61- }
64+ }
6265
6366 // compile
6467 options . filename = view . path ;
6568 view . fn = view . templateEngine . compile ( view . contents , options ) ;
6669 cache [ cid ] = view ;
67-
70+
6871 return view ;
6972} ;
7073
@@ -81,11 +84,11 @@ exports.compile = function(view, cache, cid, options){
8184 *
8285 * Lookup:
8386 *
84- * - partial `_<name>`
85- * - any `<name>/index`
86- * - non-layout `../<name>/index`
87- * - any `<root>/<name>`
88- * - partial `<root>/_<name>`
87+ * - partial `_<name>`
88+ * - any `<name>/index`
89+ * - non-layout `../<name>/index`
90+ * - any `<root>/<name>`
91+ * - partial `<root>/_<name>`
8992 *
9093 * @param {String } view
9194 * @param {Object } options
@@ -161,7 +164,7 @@ function renderPartial(res, view, options, parentLocals, parent){
161164
162165 // Inherit locals from parent
163166 union ( options , parentLocals ) ;
164-
167+
165168 // Merge locals
166169 if ( locals ) merge ( options , locals ) ;
167170
@@ -202,7 +205,7 @@ function renderPartial(res, view, options, parentLocals, parent){
202205 options . lastInCollection = i == len - 1 ;
203206 object = val ;
204207 buf += render ( ) ;
205- }
208+ }
206209 } else {
207210 keys = Object . keys ( collection ) ;
208211 len = keys . length ;
@@ -227,20 +230,20 @@ function renderPartial(res, view, options, parentLocals, parent){
227230} ;
228231
229232/**
230- * Render `view` partial with the given `options`. Optionally a
233+ * Render `view` partial with the given `options`. Optionally a
231234 * callback `fn(err, str)` may be passed instead of writing to
232235 * the socket.
233236 *
234237 * Options:
235238 *
236- * - `object` Single object with name derived from the view (unless `as` is present)
239+ * - `object` Single object with name derived from the view (unless `as` is present)
237240 *
238241 * - `as` Variable name for each `collection` value, defaults to the view name.
239242 * * as: 'something' will add the `something` local variable
240243 * * as: this will use the collection value as the template context
241244 * * as: global will merge the collection value's properties with `locals`
242245 *
243- * - `collection` Array of objects, the name is derived from the view name itself.
246+ * - `collection` Array of objects, the name is derived from the view name itself.
244247 * For example _video.html_ will have a object _video_ available to it.
245248 *
246249 * @param {String } view
@@ -294,7 +297,7 @@ res.partial = function(view, options, fn){
294297 * automatically, however otherwise a response of _200_ and _text/html_ is given.
295298 *
296299 * Options:
297- *
300+ *
298301 * - `scope` Template evaluation context (the value of `this`)
299302 * - `debug` Output debugging information
300303 * - `status` Response status code
@@ -430,7 +433,7 @@ res._render = function(view, opts, fn, parent, sub){
430433 // partial return
431434 } else if ( partial ) {
432435 return str ;
433- // render complete, and
436+ // render complete, and
434437 // callback given
435438 } else if ( fn ) {
436439 fn ( null , str ) ;
@@ -454,4 +457,4 @@ function hintAtViewPaths(view, options) {
454457 console . error ( ' - %s' , path ) ;
455458 } ) ;
456459 console . error ( ) ;
457- }
460+ }
0 commit comments