Skip to content

Commit

Permalink
Merge pull request #2 from marko-js/issue-1
Browse files Browse the repository at this point in the history
fix: issue printing destructured tag params
  • Loading branch information
DylanPiercey authored Oct 13, 2021
2 parents 7582c5c + f9db3b2 commit 6451e1f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<macro name="recursive">
<await(generator.next())>
<@then|{ value, done }|>
<div>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
</div>
</@then>
</await>
</macro>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
macro name="recursive"
await(generator.next())
@then|{ value, done }|
div
ul
li -- ${value}
ul
li -- ${value}
ul
li -- ${value}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<macro name="recursive">
<await(generator.next())>
<@then|{ value, done }|>
<div>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
</div>
</@then>
</await>
</macro>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<macro name="recursive">
<await(generator.next())>
<@then|{ value, done }|>
<div>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
</div>
</@then>
</await>
</macro>
11 changes: 11 additions & 0 deletions src/__tests__/fixtures/params-destructured.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<macro name="recursive">
<await(generator.next())>
<@then|{ value, done }|>
<div>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
<ul><li>${value}</li></ul>
</div>
</@then>
</await>
</macro>
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,11 @@ export const printers: Record<string, Printer<Node>> = {
"__js_expression",
(doc: any) => {
const { contents } = doc.contents[0];
if (Array.isArray(contents) && contents[0] === "(") {
return contents.slice(1, -1);
if (Array.isArray(contents) && contents[0].startsWith("(")) {
contents[0] = contents[0].slice(1);
contents[contents.length - 1] = contents[
contents.length - 1
].slice(0, -1);
}

return contents;
Expand Down

0 comments on commit 6451e1f

Please sign in to comment.