Skip to content

Commit 4e88a2b

Browse files
committed
fix: handle route target subExpression
fixes #164
1 parent 76df4fb commit 4e88a2b

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

transforms/angle-brackets/test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,3 +957,27 @@ test('preserve arguments', () => {
957957
"
958958
`);
959959
});
960+
961+
test('handles link-to concat', () => {
962+
let input = `
963+
{{#link-to (concat someVariable ".detail") class="some-class"}}click{{/link-to}}
964+
`;
965+
966+
expect(runTest('handles-link-to-concat.hbs', input)).toMatchInlineSnapshot(`
967+
"
968+
<LinkTo @route={{concat someVariable \\".detail\\"}} class=\\"some-class\\">click</LinkTo>
969+
"
970+
`);
971+
});
972+
973+
test('handles link-to concat with hash', () => {
974+
let input = `
975+
{{#link-to (random-helper someVariable ".detail" do-the="thing") class="some-class"}}click{{/link-to}}
976+
`;
977+
978+
expect(runTest('handles-link-to-concat.hbs', input)).toMatchInlineSnapshot(`
979+
"
980+
<LinkTo @route={{random-helper someVariable \\".detail\\" do-the=\\"thing\\"}} class=\\"some-class\\">click</LinkTo>
981+
"
982+
`);
983+
});

transforms/angle-brackets/transform.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ function transformToAngleBracket(env, fileInfo, config) {
228228
firstParamOutput = b.attr('@query', b.mustache(b.path('hash'), [], firstParamInput.hash));
229229
} else if (firstParamInput.type === 'PathExpression') {
230230
firstParamOutput = b.attr('@route', b.mustache(firstParamInput.original));
231+
} else if (firstParamInput.type === 'SubExpression') {
232+
firstParamOutput = b.attr(
233+
'@route',
234+
b.mustache(firstParamInput.path, firstParamInput.params, firstParamInput.hash)
235+
);
231236
} else {
232237
firstParamOutput = b.attr('@route', b.text(firstParamInput.value));
233238
}

0 commit comments

Comments
 (0)