Skip to content

Commit dcfb5c7

Browse files
committed
Reach parity with Liquid 5.11.0
1 parent cb77229 commit dcfb5c7

File tree

9 files changed

+8
-72
lines changed

9 files changed

+8
-72
lines changed

.changeset/wicked-candles-bathe.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@shopify/prettier-plugin-liquid': minor
3+
'@shopify/liquid-html-parser': minor
4+
'@shopify/theme-check-common': minor
5+
---
6+
7+
Reach parity with Liquid 5.11.0

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ Liquid <: Helpers {
7878
| liquidTagOpenIf
7979
| liquidTagOpenPaginate
8080
| liquidTagOpenUnless
81-
| liquidTagOpenSnippet
8281

8382
liquidTagOpen =
8483
| liquidTagOpenStrict
@@ -106,7 +105,6 @@ Liquid <: Helpers {
106105
liquidTagIncrement = liquidTagRule<"increment", variableSegmentAsLookupMarkup>
107106
liquidTagDecrement = liquidTagRule<"decrement", variableSegmentAsLookupMarkup>
108107
liquidTagOpenCapture = liquidTagOpenRule<"capture", variableSegmentAsLookupMarkup>
109-
liquidTagOpenSnippet = liquidTagOpenRule<"snippet", variableSegmentAsLookupMarkup>
110108
variableSegmentAsLookupMarkup = variableSegmentAsLookup space*
111109

112110
liquidTagSection = liquidTagRule<"section", liquidTagSectionMarkup>
@@ -324,7 +322,6 @@ Liquid <: Helpers {
324322
| "if"
325323
| "unless"
326324
| "tablerow"
327-
| "snippet"
328325
) endOfIdentifier
329326

330327
delimTag = "-%}" | "%}"

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -794,17 +794,6 @@ describe('Unit: Stage 1 (CST)', () => {
794794
});
795795
});
796796

797-
it('should parse snippet arguments as a singular liquid variable lookup', () => {
798-
const expression = `var`;
799-
const type = 'VariableLookup';
800-
for (const { toCST, expectPath } of testCases) {
801-
cst = toCST(`{% snippet ${expression} -%}`);
802-
expectPath(cst, '0.type').to.equal('LiquidTagOpen');
803-
expectPath(cst, '0.name').to.equal('snippet');
804-
expectPath(cst, '0.markup.type').to.equal(type);
805-
}
806-
});
807-
808797
it('should parse when arguments as an array of liquid expressions', () => {
809798
[
810799
{ expression: `"string"`, args: [{ type: 'String' }] },

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ export type ConcreteLiquidTagOpen = ConcreteLiquidTagOpenBaseCase | ConcreteLiqu
237237
export type ConcreteLiquidTagOpenNamed =
238238
| ConcreteLiquidTagOpenCase
239239
| ConcreteLiquidTagOpenCapture
240-
| ConcreteLiquidTagOpenSnippet
241240
| ConcreteLiquidTagOpenIf
242241
| ConcreteLiquidTagOpenUnless
243242
| ConcreteLiquidTagOpenForm
@@ -255,8 +254,6 @@ export interface ConcreteLiquidTagOpenBaseCase extends ConcreteLiquidTagOpenNode
255254

256255
export interface ConcreteLiquidTagOpenCapture
257256
extends ConcreteLiquidTagOpenNode<NamedTags.capture, ConcreteLiquidVariableLookup> {}
258-
export interface ConcreteLiquidTagOpenSnippet
259-
extends ConcreteLiquidTagOpenNode<NamedTags.snippet, ConcreteLiquidVariableLookup> {}
260257

261258
export interface ConcreteLiquidTagOpenCase
262259
extends ConcreteLiquidTagOpenNode<NamedTags.case, ConcreteLiquidExpression> {}
@@ -749,7 +746,6 @@ function toCST<T>(
749746
},
750747

751748
liquidTagOpenCapture: 0,
752-
liquidTagOpenSnippet: 0,
753749
liquidTagOpenForm: 0,
754750
liquidTagOpenFormMarkup: 0,
755751
liquidTagOpenFor: 0,

packages/liquid-html-parser/src/stage-2-ast.spec.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -637,25 +637,6 @@ describe('Unit: Stage 2 (AST)', () => {
637637
});
638638
});
639639

640-
it('should parse snippet blocks', () => {
641-
for (const { toAST, expectPath, expectPosition } of testCases) {
642-
ast = toAST(`{% snippet hello_snippet %}{% echo "Hello content" %}{% endsnippet %}`);
643-
expectPath(ast, 'children.0').to.exist;
644-
expectPath(ast, 'children.0.type').to.eql('LiquidTag');
645-
expectPath(ast, 'children.0.name').to.eql('snippet');
646-
expectPath(ast, 'children.0.markup.type').to.eql('VariableLookup');
647-
expectPath(ast, 'children.0.markup.name').to.eql('hello_snippet');
648-
649-
expectPath(ast, 'children.0.children.0.type').to.eql('LiquidTag');
650-
expectPath(ast, 'children.0.children.0.name').to.eql('echo');
651-
expectPath(ast, 'children.0.children.0.markup.type').to.eql('LiquidVariable');
652-
expectPath(ast, 'children.0.children.0.markup.expression.value').to.eql('Hello content');
653-
654-
expectPosition(ast, 'children.0');
655-
expectPosition(ast, 'children.0.markup');
656-
}
657-
});
658-
659640
describe('Case: content_for', () => {
660641
it('should parse content_for tags with no arguments', () => {
661642
for (const { toAST, expectPath, expectPosition } of testCases) {
@@ -1249,25 +1230,6 @@ describe('Unit: Stage 2 (AST)', () => {
12491230
expectPosition(ast, 'children.0.body.nodes.2').toEqual('}');
12501231
expectPosition(ast, 'children.0');
12511232
});
1252-
1253-
it('should parse snippet blocks with HTML content', () => {
1254-
ast = toLiquidHtmlAST(
1255-
`{% snippet hello_snippet %}<div class="component"><p>Hello</p></div>{% endsnippet %}`,
1256-
);
1257-
expectPath(ast, 'children.0.type').to.eql('LiquidTag');
1258-
expectPath(ast, 'children.0.name').to.eql('snippet');
1259-
expectPath(ast, 'children.0.markup.type').to.eql('VariableLookup');
1260-
expectPath(ast, 'children.0.markup.name').to.eql('hello_snippet');
1261-
expectPath(ast, 'children.0.children.0.type').to.eql('HtmlElement');
1262-
expectPath(ast, 'children.0.children.0.name.0.value').to.eql('div');
1263-
expectPath(ast, 'children.0.children.0.attributes.0.name.0.value').to.eql('class');
1264-
expectPath(ast, 'children.0.children.0.attributes.0.value.0.value').to.eql('component');
1265-
expectPath(ast, 'children.0.children.0.children.0.type').to.eql('HtmlElement');
1266-
expectPath(ast, 'children.0.children.0.children.0.name.0.value').to.eql('p');
1267-
expectPath(ast, 'children.0.children.0.children.0.children.0.type').to.eql('TextNode');
1268-
expectPath(ast, 'children.0.children.0.children.0.children.0.value').to.eql('Hello');
1269-
expectPosition(ast, 'children.0');
1270-
});
12711233
});
12721234

12731235
describe('Unit: toLiquidAST(text)', () => {

packages/liquid-html-parser/src/stage-2-ast.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ export type LiquidTagNamed =
212212
| LiquidTagRender
213213
| LiquidTagSection
214214
| LiquidTagSections
215-
| LiquidTagSnippet
216215
| LiquidTagTablerow
217216
| LiquidTagUnless;
218217

@@ -279,9 +278,6 @@ export interface LiquidTagDecrement
279278
/** https://shopify.dev/docs/api/liquid/tags#capture */
280279
export interface LiquidTagCapture extends LiquidTagNode<NamedTags.capture, LiquidVariableLookup> {}
281280

282-
/** https://shopify.dev/docs/api/liquid/tags#snippet */
283-
export interface LiquidTagSnippet extends LiquidTagNode<NamedTags.snippet, LiquidVariableLookup> {}
284-
285281
/** https://shopify.dev/docs/api/liquid/tags#cycle */
286282
export interface LiquidTagCycle extends LiquidTagNode<NamedTags.cycle, CycleMarkup> {}
287283

@@ -1548,15 +1544,6 @@ function toNamedLiquidTag(
15481544
};
15491545
}
15501546

1551-
case NamedTags.snippet: {
1552-
return {
1553-
...liquidTagBaseAttributes(node),
1554-
name: node.name,
1555-
markup: toExpression(node.markup) as LiquidVariableLookup,
1556-
children: [],
1557-
};
1558-
}
1559-
15601547
case NamedTags.content_for: {
15611548
return {
15621549
...liquidTagBaseAttributes(node),

packages/liquid-html-parser/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export enum NamedTags {
7070
layout = 'layout',
7171
liquid = 'liquid',
7272
paginate = 'paginate',
73-
snippet = 'snippet',
7473
render = 'render',
7574
section = 'section',
7675
sections = 'sections',

packages/prettier-plugin-liquid/src/printer/print/liquid.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ function printNamedLiquidBlockStart(
189189
}
190190

191191
case NamedTags.capture:
192-
case NamedTags.snippet:
193192
case NamedTags.increment:
194193
case NamedTags.decrement:
195194
case NamedTags.layout:

packages/theme-check-common/src/checks/liquid-html-syntax-error/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('Module: LiquidHTMLSyntaxError', () => {
8686
const offenses = await runLiquidCheck(LiquidHTMLSyntaxError, sourceCode);
8787
expect(offenses).to.have.length(1);
8888
expect(offenses[0].message).to.equal(
89-
`SyntaxError: expected "#", a letter, "when", "sections", "section", "render", "liquid", "layout", "increment", "include", "elsif", "else", "echo", "decrement", "content_for", "cycle", "continue", "break", "assign", "snippet", "tablerow", "unless", "if", "ifchanged", "for", "case", "capture", "paginate", "form", "end", "style", "stylesheet", "schema", "javascript", "raw", "comment", or "doc"`,
89+
`SyntaxError: expected "#", a letter, "when", "sections", "section", "render", "liquid", "layout", "increment", "include", "elsif", "else", "echo", "decrement", "content_for", "cycle", "continue", "break", "assign", "tablerow", "unless", "if", "ifchanged", "for", "case", "capture", "paginate", "form", "end", "style", "stylesheet", "schema", "javascript", "raw", "comment", or "doc"`,
9090
);
9191
});
9292

0 commit comments

Comments
 (0)