mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
Added view index resolution support
This commit is contained in:
parent
42ea6af1eb
commit
a54e59666a
|
|
@ -37,7 +37,7 @@ var users = [
|
|||
];
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.render('user/list', { users: users });
|
||||
res.render('users', { users: users });
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ var utils = require('../utils')
|
|||
|
||||
var cache = {};
|
||||
|
||||
/**
|
||||
* Existance cache.
|
||||
*/
|
||||
|
||||
var exists = {};
|
||||
|
||||
/**
|
||||
* Initialize a new `View` with the given `view` path and `options`.
|
||||
*
|
||||
|
|
@ -53,11 +59,16 @@ var View = exports = module.exports = function View(view, options) {
|
|||
*/
|
||||
|
||||
View.prototype.__defineGetter__('exists', function(){
|
||||
try {
|
||||
stat(this.path);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
var path = this.path;
|
||||
if (null != exists[path]) {
|
||||
return exists[path];
|
||||
} else {
|
||||
try {
|
||||
stat(path);
|
||||
return exists[path] = true;
|
||||
} catch (err) {
|
||||
return exists[path] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ module.exports = {
|
|||
{ url: '/nope' },
|
||||
function(res){
|
||||
assert.ok(res.body.indexOf('Error: ENOENT') >= 0);
|
||||
assert.ok(res.body.indexOf('nope.jade') >= 0);
|
||||
assert.ok(res.body.indexOf('nope/index.jade') >= 0);
|
||||
});
|
||||
|
||||
beforeExit(function(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user