Skip to content

Commit 757f7de

Browse files
committed
fix: concat expression inside html attribute value
Close GH-110
1 parent 51f1014 commit 757f7de

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## unreleased
44

5+
### Bugfix
6+
- [GH-110](https://github.com/zackad/prettier-plugin-twig/issues/90) Fix regression when parsing concatenation expression inside html attribute value
7+
58
### Internals
69
- DX: Don't use alias to export print function to make it easier to identify when debugging call stack
710

src/melody/melody-parser/Lexer.js

+3
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ export default class Lexer {
578578
if (c === "\\" && input.la(1) === start) {
579579
input.next();
580580
input.next();
581+
} else if (c === "{" && input.la(1) === "{") {
582+
// interpolation start
583+
break;
581584
} else if (c === start) {
582585
break;
583586
} else {

tests/Element/__snapshots__/attributes.snap.twig

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{# https://github.com/zackad/prettier-plugin-twig/issues/110 #}
2+
<section class="sm:p-0 p-0 text-{{ i }}"></section>
3+
14
<a href="#abcd" target="_blank" lang="en">Link</a>
25

36
<fantasy

tests/Element/attributes.twig

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{# https://github.com/zackad/prettier-plugin-twig/issues/110 #}
2+
<section class="sm:p-0 p-0 text-{{ i }}"></section>
3+
14
<a href="#abcd" target="_blank" lang="en" >Link</a>
25

36
<fantasy {{ {

0 commit comments

Comments
 (0)