Permalink
Browse files

Fixed try/catch issue with renderFile(). Closes #227

  • Loading branch information...
tj committed May 24, 2011
1 parent d1d2c27 commit 29b661053e82dfe3fe902394b19e5c038ff0223a
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/jade.js
View
@@ -285,6 +285,8 @@ exports.render = function(str, options){
*/
exports.renderFile = function(path, options, fn){
+ var ret;
+
if (typeof options === 'function') {
fn = options;
options = {};
@@ -294,18 +296,20 @@ exports.renderFile = function(path, options, fn){
// Primed cache
if (options.cache && cache[path]) {
try {
- fn(null, exports.render('', options));
+ ret = exports.render('', options);
} catch (err) {
- fn(err);
+ return fn(err);
}
+ fn(null, ret);
} else {
fs.readFile(path, 'utf8', function(err, str){
if (err) return fn(err);
try {
- fn(null, exports.render(str, options));
+ ret = exports.render(str, options);
} catch (err) {
- fn(err);
+ return fn(err);
}
+ fn(null, ret);
});
}
};

0 comments on commit 29b6610

Please sign in to comment.