diff options
-rw-r--r-- | dist/handlebars.js | 11 | ||||
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 11 | ||||
-rw-r--r-- | spec/qunit_spec.js | 13 |
3 files changed, 35 insertions, 0 deletions
diff --git a/dist/handlebars.js b/dist/handlebars.js index 4ce69df..3cfb57d 100644 --- a/dist/handlebars.js +++ b/dist/handlebars.js @@ -897,6 +897,17 @@ Compiler.prototype = { } } } + + len = this.children.length; + if (other.children.length !== len) { + return false; + } + for (i = 0; i < len; i++) { + if (!this.children[i].equals(other.children[i])) { + return false; + } + } + return true; }, diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js index 2ab1b73..196ba18 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -59,6 +59,17 @@ Compiler.prototype = { } } } + + len = this.children.length; + if (other.children.length !== len) { + return false; + } + for (i = 0; i < len; i++) { + if (!this.children[i].equals(other.children[i])) { + return false; + } + } + return true; }, diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js index dadccef..f12e44c 100644 --- a/spec/qunit_spec.js +++ b/spec/qunit_spec.js @@ -1384,3 +1384,16 @@ test('GH-408: Multiple loops fail', function() { var result = template(context); equals(result, "John DoeJane DoeJohn DoeJane DoeJohn DoeJane Doe", 'It should output multiple times'); }); + +test('GS-428: Nested if else rendering', function() { + var succeedingTemplate = '{{#inverse}} {{#blk}} Unexpected {{/blk}} {{else}} {{#blk}} Expected {{/blk}} {{/inverse}}'; + var failingTemplate = '{{#inverse}} {{#blk}} Unexpected {{/blk}} {{else}} {{#blk}} Expected {{/blk}} {{/inverse}}'; + + var helpers = { + blk: function(block) { return block.fn(''); }, + inverse: function(block) { return block.inverse(''); } + }; + + shouldCompileTo(succeedingTemplate, [{}, helpers], ' Expected '); + shouldCompileTo(failingTemplate, [{}, helpers], ' Expected '); +}); |