Skip to content

Commit

Permalink
Fixed up index view path alternative
Browse files Browse the repository at this point in the history
previously was doing ../index, which was not intended
now doing ../VIEW/index
  • Loading branch information
tj committed Mar 17, 2011
1 parent a254e64 commit 220d88d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/view.js
Expand Up @@ -272,7 +272,8 @@ res.render = function(view, opts, fn, parent, sub){
// Try index ex: ./views/user/index.jade
if (!view.exists) view = new View(orig.indexPath, options);

// Try ../name ../user from within ./user
// Try ../<name>/index ex: ../user/index.jade
// when calling partial('user') within the same dir
if (!view.exists && !options.isLayout) view = new View(orig.upIndexPath, options);

// Try layout relative to the "views" dir
Expand Down
5 changes: 3 additions & 2 deletions lib/view/view.js
Expand Up @@ -47,6 +47,7 @@ var View = exports = module.exports = function View(view, options) {
this.basename = basename(view);
this.engine = this.resolveEngine();
this.extension = '.' + this.engine;
this.name = this.basename.replace(this.extension, '');
this.path = this.resolvePath();
this.dirname = dirname(this.path);
};
Expand Down Expand Up @@ -160,14 +161,14 @@ View.prototype.__defineGetter__('indexPath', function(){
});

/**
* Return ../index path alternative.
* Return ../<name>/index path alternative.
*
* @return {String}
* @api public
*/

View.prototype.__defineGetter__('upIndexPath', function(){
return this.dirname + '/index' + this.extension;
return this.dirname + '/../' + this.name + '/index' + this.extension;
});

/**
Expand Down

0 comments on commit 220d88d

Please sign in to comment.