Skip to content

Commit

Permalink
Merge pull request #996 from rgallagherab/issue-995
Browse files Browse the repository at this point in the history
Fix parsing error when in-tag string content contains `>`
  • Loading branch information
bmish committed Jul 24, 2024
2 parents 30d2220 + 2225813 commit d8c920d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/parse-result.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { builders, parse, print, transform } from '.';
import { builders, parse, print, transform, traverse } from '.';
import type { ASTv1 as AST } from '@glimmer/syntax';
import stripIndent from 'outdent';

Expand Down Expand Up @@ -550,6 +550,25 @@ describe('ember-template-recast', function () {
`);
});

test('issue can handle angle brackets in modifier argument values', function () {
let template = `
<Select
@placeholder={{do-something ">> Some Text Here"}}
@options={{this.items}}
as |item|
>
{{item.name}}
</Select>
`;
let ast = parse(template);
traverse(ast, {
ElementNode(node) {
node.tag = `${node.tag}`;
},
});
expect(print(ast)).toEqual(template);
});

test('issue 706', function () {
let template = `<div
class="pt-2 pb-4 {{this.foo}}"
Expand Down
5 changes: 4 additions & 1 deletion src/parse-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,10 @@ export default class ParseResult {
blockParamsEndIndex + 1
);

const closeOpenIndex = nodeInfo.source.indexOf(selfClosing ? '/>' : '>');
// Match closing index after start of block params to avoid closing tag if /> or > encountered in string
const closeOpenIndex =
nodeInfo.source.substring(blockParamStartIndex).indexOf(selfClosing ? '/>' : '>') +
blockParamStartIndex;
postBlockParamsWhitespace = nodeInfo.source.substring(
blockParamsEndIndex + 1,
closeOpenIndex
Expand Down

0 comments on commit d8c920d

Please sign in to comment.