Permalink
Browse files

Inverted the cache-check if statement

  • Loading branch information...
1 parent 2a8d8be commit 3a8debb8fc32e071f59c2e850a292509475a0118 @cjoudrey cjoudrey committed Feb 8, 2011
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/haml.js
View
13 lib/haml.js
@@ -666,7 +666,6 @@ exports.render = function(str, options) {
}).call(options.context)
}
-
/**
* Render a file containing haml and cache the parser.
*
@@ -681,19 +680,19 @@ exports.render = function(str, options) {
exports.renderFile = function(filename, encoding, options, callback) {
options = options || {}
options.filename = options.filename || filename
- options.cache = true
+ options.cache = options.hasOwnProperty('cache') ? options.cache : true
- if (!exports.cache[filename]) {
+ if (exports.cache[filename]) {
+ process.nextTick(function() {
+ callback(null, exports.render(null, options))
+ });
+ } else {
fs.readFile(filename, encoding, function(err, str) {
if (err) {
callback(err)
} else {
callback(null, exports.render(str, options))
}
});
- } else {
- process.nextTick(function() {
- callback(null, exports.render(null, options))
- });
}
}

0 comments on commit 3a8debb

Please sign in to comment.