Skip to content

Commit 70e2241

Browse files
committedSep 5, 2024··
Fix broken parsing of liquid attribute names

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
 

‎.changeset/wicked-balloons-reply.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/liquid-html-parser': patch
3+
---
4+
5+
Fix broken parsing of liquid attribute names

‎packages/liquid-html-parser/grammar/liquid-html.ohm

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ LiquidHTML <: Liquid {
430430
AttrList = Attr*
431431

432432
Attr =
433-
liquidNode | AttrSingleQuoted | AttrDoubleQuoted | AttrUnquoted | attrEmpty
433+
AttrSingleQuoted | AttrDoubleQuoted | AttrUnquoted | liquidNode | attrEmpty
434434

435435
attrEmpty = attrName
436436

‎packages/liquid-html-parser/src/stage-1-cst.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,19 @@ describe('Unit: Stage 1 (CST)', () => {
11071107
});
11081108
});
11091109

1110+
it('should parse liquid attribute names', () => {
1111+
cst = toLiquidHtmlCST('<img {{ data-name }}="{{ data-value }}"/>');
1112+
expectPath(cst, '0.name').to.equal('img');
1113+
expectPath(cst, '0.type').to.equal('HtmlVoidElement');
1114+
expectPath(cst, '0.attrList.0.type').to.equal('AttrDoubleQuoted');
1115+
expectPath(cst, '0.attrList.0.name.0.type').to.equal('LiquidVariableOutput');
1116+
expectPath(cst, '0.attrList.0.name.0.markup.expression.type').to.equal('VariableLookup');
1117+
expectPath(cst, '0.attrList.0.name.0.markup.expression.name').to.equal('data-name');
1118+
expectPath(cst, '0.attrList.0.value.0.type').to.equal('LiquidVariableOutput');
1119+
expectPath(cst, '0.attrList.0.value.0.markup.expression.type').to.equal('VariableLookup');
1120+
expectPath(cst, '0.attrList.0.value.0.markup.expression.name').to.equal('data-value');
1121+
});
1122+
11101123
it(`should parse quoted attributes`, () => {
11111124
[
11121125
{ type: 'AttrSingleQuoted', name: 'single', quote: "'" },

0 commit comments

Comments
 (0)
Please sign in to comment.