Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/whitespace-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ WhitespaceControl.prototype.Program = function (program) {
// Always strip the next node
omitRight(body, i);

omitLeft((current.inverse || current.program).body);
let lastInverse = current.inverse || current.program;
while (lastInverse.chained) {
let child = lastInverse.body[lastInverse.body.length - 1]
lastInverse = child.inverse || child.program
}

omitLeft(lastInverse.body);
}
}

Expand Down
5 changes: 5 additions & 0 deletions spec/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ describe('ast', function () {
equals(ast.body[0].value, '');
equals(ast.body[1].program.body[0].value, 'foo');
});

it('chained block statements', function () {
let ast = parse('{{#if false}}\n{{else if false}}\n{{else}}\n\t{{/if}}');
equals(ast.body[0].inverse.body[0].inverse.body[0].value, '');
})
});

describe('parseWithoutProcessing', function () {
Expand Down
4 changes: 4 additions & 0 deletions spec/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ describe('parser', function () {
'{{#foo}} bar {{else if bar}}{{else}} baz {{/foo}}',
"BLOCK:\n p%foo\n PROGRAM:\n CONTENT[ ' bar ' ]\n {{^}}\n BLOCK:\n p%if [p%bar]\n PROGRAM:\n {{^}}\n CONTENT[ ' baz ' ]"
);
equalsAst(
'\t{{#if false}}\n\t{{else if false}}\n\t{{else}}\n\t{{/if}}',
"CONTENT[ '' ]\nBLOCK:\n p%if [b%false]\n PROGRAM:\n CONTENT[ '' ]\n {{^}}\n BLOCK:\n p%if [b%false]\n PROGRAM:\n CONTENT[ '' ]\n {{^}}\n CONTENT[ '' ]"
);
});

it('parses empty blocks', function () {
Expand Down