Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix extra spaces in block params #1577

Merged
merged 3 commits into from
Apr 4, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ export class TokenizerEventHandlers extends HandlebarsNodeVisitors {
);
} else {
state = { state: 'AfterEndPipe' };
this.tokenizer.consume();
}
} else if (next === '>' || next === '/') {
throw generateSyntaxError(
Expand Down
34 changes: 34 additions & 0 deletions packages/@glimmer/syntax/test/parser-node-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,25 @@ test('block with block params', () => {
);
});

test('block with block params edge case: extra spaces', () => {
let t = `{{#foo as | bar bat baz |}}{{bar}} {{bat}} {{baz}}{{/foo}}`;

astEqual(
t,
b.template([
b.block(
b.path('foo'),
null,
null,
b.blockItself(
[b.mustache('bar'), b.text(' '), b.mustache('bat'), b.text(' '), b.mustache('baz')],
['bar', 'bat', 'baz']
)
),
])
);
});

test('block with block params edge case: multiline', () => {
let t = `{{#foo as
|bar bat
Expand Down Expand Up @@ -389,6 +408,21 @@ test('element with block params', () => {
);
});

test('element with block params edge case: extra spaces', () => {
let t = `<Foo as | bar bat baz |>{{bar}} {{bat}} {{baz}}</Foo>`;

astEqual(
t,
b.template([
element(
'Foo',
['as', b.var('bar'), b.var('bat'), b.var('baz')],
['body', b.mustache('bar'), b.text(' '), b.mustache('bat'), b.text(' '), b.mustache('baz')]
),
])
);
});

test('element with block params edge case: multiline', () => {
let t = `<Foo as
|bar bat
Expand Down
Loading