Allow blockParams on chained inverse statements
This commit is contained in:
@@ -166,6 +166,9 @@ describe('parser', function() {
|
||||
it('parses inverse block with block params', function() {
|
||||
equals(ast_for("{{^foo as |bar baz|}}content{{/foo}}"), "BLOCK:\n PATH:foo []\n {{^}}\n BLOCK PARAMS: [ bar baz ]\n CONTENT[ 'content' ]\n");
|
||||
});
|
||||
it('parses chained inverse block with block params', function() {
|
||||
equals(ast_for("{{#foo}}{{else foo as |bar baz|}}content{{/foo}}"), "BLOCK:\n PATH:foo []\n PROGRAM:\n {{^}}\n BLOCK:\n PATH:foo []\n PROGRAM:\n BLOCK PARAMS: [ bar baz ]\n CONTENT[ 'content' ]\n");
|
||||
});
|
||||
it("raises if there's a Parse error", function() {
|
||||
shouldThrow(function() {
|
||||
ast_for("foo{{^}}bar");
|
||||
|
||||
+7
-3
@@ -1,3 +1,4 @@
|
||||
/*global Handlebars */
|
||||
function shouldMatchTokens(result, tokens) {
|
||||
for (var index = 0; index < result.length; index++) {
|
||||
equals(result[index].name, tokens[index]);
|
||||
@@ -404,13 +405,16 @@ describe('Tokenizer', function() {
|
||||
var result = tokenize("{{#foo as |bar|}}");
|
||||
shouldMatchTokens(result, ['OPEN_BLOCK', 'ID', 'OPEN_BLOCK_PARAMS', 'ID', 'CLOSE_BLOCK_PARAMS', 'CLOSE']);
|
||||
|
||||
var result = tokenize("{{#foo as |bar baz|}}");
|
||||
result = tokenize("{{#foo as |bar baz|}}");
|
||||
shouldMatchTokens(result, ['OPEN_BLOCK', 'ID', 'OPEN_BLOCK_PARAMS', 'ID', 'ID', 'CLOSE_BLOCK_PARAMS', 'CLOSE']);
|
||||
|
||||
var result = tokenize("{{#foo as | bar baz |}}");
|
||||
result = tokenize("{{#foo as | bar baz |}}");
|
||||
shouldMatchTokens(result, ['OPEN_BLOCK', 'ID', 'OPEN_BLOCK_PARAMS', 'ID', 'ID', 'CLOSE_BLOCK_PARAMS', 'CLOSE']);
|
||||
|
||||
var result = tokenize("{{#foo as as | bar baz |}}");
|
||||
result = tokenize("{{#foo as as | bar baz |}}");
|
||||
shouldMatchTokens(result, ['OPEN_BLOCK', 'ID', 'ID', 'OPEN_BLOCK_PARAMS', 'ID', 'ID', 'CLOSE_BLOCK_PARAMS', 'CLOSE']);
|
||||
|
||||
result = tokenize("{{else foo as |bar baz|}}");
|
||||
shouldMatchTokens(result, ['OPEN_INVERSE_CHAIN', 'ID', 'OPEN_BLOCK_PARAMS', 'ID', 'ID', 'CLOSE_BLOCK_PARAMS', 'CLOSE']);
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ openInverse
|
||||
;
|
||||
|
||||
openInverseChain
|
||||
: OPEN_INVERSE_CHAIN sexpr CLOSE -> yy.prepareMustache($2, $1, yy.stripFlags($1, $3), @$)
|
||||
: OPEN_INVERSE_CHAIN sexpr blockParams? CLOSE -> { sexpr: $2, blockParams: $3, strip: yy.stripFlags($1, $4) }
|
||||
;
|
||||
|
||||
inverseAndProgram
|
||||
|
||||
Reference in New Issue
Block a user