Skip to content

Commit d8c920d

Browse files
authored
Merge pull request #996 from rgallagherab/issue-995
Fix parsing error when in-tag string content contains `>`
2 parents 30d2220 + 2225813 commit d8c920d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Diff for: src/parse-result.test.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { builders, parse, print, transform } from '.';
1+
import { builders, parse, print, transform, traverse } from '.';
22
import type { ASTv1 as AST } from '@glimmer/syntax';
33
import stripIndent from 'outdent';
44

@@ -550,6 +550,25 @@ describe('ember-template-recast', function () {
550550
`);
551551
});
552552

553+
test('issue can handle angle brackets in modifier argument values', function () {
554+
let template = `
555+
<Select
556+
@placeholder={{do-something ">> Some Text Here"}}
557+
@options={{this.items}}
558+
as |item|
559+
>
560+
{{item.name}}
561+
</Select>
562+
`;
563+
let ast = parse(template);
564+
traverse(ast, {
565+
ElementNode(node) {
566+
node.tag = `${node.tag}`;
567+
},
568+
});
569+
expect(print(ast)).toEqual(template);
570+
});
571+
553572
test('issue 706', function () {
554573
let template = `<div
555574
class="pt-2 pb-4 {{this.foo}}"

Diff for: src/parse-result.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,10 @@ export default class ParseResult {
513513
blockParamsEndIndex + 1
514514
);
515515

516-
const closeOpenIndex = nodeInfo.source.indexOf(selfClosing ? '/>' : '>');
516+
// Match closing index after start of block params to avoid closing tag if /> or > encountered in string
517+
const closeOpenIndex =
518+
nodeInfo.source.substring(blockParamStartIndex).indexOf(selfClosing ? '/>' : '>') +
519+
blockParamStartIndex;
517520
postBlockParamsWhitespace = nodeInfo.source.substring(
518521
blockParamsEndIndex + 1,
519522
closeOpenIndex

0 commit comments

Comments
 (0)