Repository: mozilla/nunjucks (js)

Issue:
Template error supressed when it's included inside {% if %}
I have a template with an error, i.e. like `bad.html`:

     {% fail %}some output

When I include this file I get a proper error message:

    {% include './bad.html' %}

    Template render error: (backend/src/views/test/include.html)
     Template render error: (backend/src/views/test/bad.html) [Line 1, Column 2]
     unknown block tag: fail

However when I include this file inside an `{% if %}` tag I get no error:

    {% if true %}
    {% include './bad.html' %}
    {% endif %}

The included template just stops rendering at the point of failure, I see neither `some output` nor error message.

Pull request description:
fix #571, make asyncif handle error
Fix #571.

Patch:
diff --git a/src/compiler.js b/src/compiler.js
index e0a0526..646a93f 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -581,7 +581,7 @@ var Compiler = Object.extend({
     compileIfAsync: function(node, frame) {
         this.emit('(function(cb) {');
         this.compileIf(node, frame, true);
-        this.emit('})(function() {');
+        this.emit('})(' + this.makeCallback());
         this.addScopeLevel();
     },
 


Test patch:
diff --git a/tests/compiler.js b/tests/compiler.js
index 5f6b3d2..85d5d39 100644
--- a/tests/compiler.js
+++ b/tests/compiler.js
@@ -1209,6 +1209,20 @@
             finish(done);
         });
 
+        it('should throw an error when including a file that calls an undefined macro even inside {% if %} tag', function(done) {
+            render(
+                '{% if true %}{% include "undefined-macro.html" %}{% endif %}',
+                {},
+                { noThrow: true },
+                function(err, res) {
+                    expect(res).to.be(undefined);
+                    expect(err).to.match(/Unable to call `\w+`, which is undefined or falsey/);
+                }
+            );
+
+            finish(done);
+        });
+
         it('should throw an error when including a file that imports macro that calls an undefined macro', function(done) {
             render(
                 '{% include "import-macro-call-undefined-macro.html" %}',