Skip to content

Commit

Permalink
Fixed issue #5 by preventing template resolve from being executed con…
Browse files Browse the repository at this point in the history
…currently
  • Loading branch information
yanickrochon committed Jun 2, 2015
1 parent 1dacc7e commit e65a22e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/engine.js
Expand Up @@ -46,6 +46,8 @@ var RenderException = require('./exceptions').RenderException;

var modifiers = {};

var resolverLocks = [];


module.exports = Engine;

Expand Down Expand Up @@ -324,6 +326,14 @@ function * resolveTemplate(name, engine) {
var file;
var found = false;


if (resolverLocks.locked) {
yield function (done) {
resolverLocks.push(done);
};
}
resolverLocks.locked = true;

if (engine.cache[name]) {
found = engine.cache[name];
} else {
Expand Down Expand Up @@ -360,6 +370,11 @@ function * resolveTemplate(name, engine) {
}
}

resolverLocks.locked = false;
if (resolverLocks.length) {
resolverLocks.pop()();
}

return found;
}

Expand Down

0 comments on commit e65a22e

Please sign in to comment.