Skip to content

Commit

Permalink
fix: closing brackets being included
Browse files Browse the repository at this point in the history
  • Loading branch information
Vehmloewff committed Aug 5, 2022
1 parent 9a2df97 commit 39634d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions compiler/attribute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ Deno.test({
)
},
})

Deno.test({
name: '[attribute] embedded expressions should work',
fn() {
test(`{hello} man that />`, { length: 7, jsString: '`${hello}`' })
},
})
4 changes: 3 additions & 1 deletion compiler/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ export function attributeToTemplateLiteral(string: string): AttributeToTemplateL

// Ok, now that we are done with the loop and we have consumed all that we would need to, we need to finish off the
// JS template literal we have started.
if (topLevelStrategy === 'quoted') jsString += '`'
// But we don't want to any closing brace to the {expression} attributes. That closing bracket was already added when the
// expression finished
if (topLevelStrategy === 'quoted' || topLevelStrategy === 'none') jsString += '`'
else jsString += '}`'

return { originalAttributeLength: consumed, jsString }
Expand Down

0 comments on commit 39634d5

Please sign in to comment.