Skip to content

Commit

Permalink
Add options to lookup call
Browse files Browse the repository at this point in the history
This allows extended view classes to implement more interesting lookup
methods without changing the interface. Removed useless ext parameter.
  • Loading branch information
aredridel committed May 19, 2015
1 parent 4846365 commit 4de612f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ app.render = function(name, options, fn){
}

if (!view.path) {
view.lookupMain(function (err) {
view.lookupMain(opts, function (err) {
if (err) return fn(err);

afterLookup();
Expand Down
8 changes: 5 additions & 3 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ function View(name, options) {
* @api private
*/

View.prototype.lookup = function lookup(name, ext, cb) {
View.prototype.lookup = function lookup(name, options, cb) {
var roots = [].concat(this.root);

debug('lookup "%s"', name);

var ext = path.extname(name);

function lookup(roots, callback) {
var root = roots.shift();
if (!root) {
Expand Down Expand Up @@ -111,13 +113,13 @@ View.prototype.render = function render(options, fn) {
* @param {function} cb
* @private
*/
View.prototype.lookupMain = function lookupMain(cb) {
View.prototype.lookupMain = function lookupMain(opts, cb) {
if (this.path) return cb();
var view = this;
var name = path.extname(this.name) == this.ext
? this.name
: this.name + this.ext;
this.lookup(name, this.ext, function (err, path) {
this.lookup(name, opts, function (err, path) {
if (err) {
return cb(err);
} else if (!path) {
Expand Down

0 comments on commit 4de612f

Please sign in to comment.