Skip to content

Commit

Permalink
Merge pull request #306 from eventEmitter/master
Browse files Browse the repository at this point in the history
async rendering doesn't throw anymore when encountering compilation errors
  • Loading branch information
garygreen committed Jan 12, 2015
2 parents 5f0c528 + 1aaec23 commit c0baa5c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,14 @@ var Template = Obj.extend({
}

return lib.withPrettyErrors(this.path, this.env.dev, function() {
this.compile();

// ctach compile errors for async rendering
try {
this.compile();
} catch (e) {
if (cb) return cb(e);
else throw e;
}

var context = new Context(ctx || {}, this.blocks);
var syncResult = null;
Expand All @@ -360,6 +367,7 @@ var Template = Obj.extend({
}.bind(this));
},


getExported: function(ctx, frame, cb) {
if (typeof ctx === 'function') {
cb = ctx;
Expand All @@ -371,7 +379,13 @@ var Template = Obj.extend({
frame = null;
}

this.compile();
// ctach compile errors for async rendering
try {
this.compile();
} catch (e) {
if (cb) return cb(e);
else throw e;
}

// Run the rootRenderFunc to populate the context with exported vars
var context = new Context(ctx || {}, this.blocks);
Expand Down

0 comments on commit c0baa5c

Please sign in to comment.