@platformos/liquid-html-parser 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/grammar.js CHANGED
@@ -23,20 +23,13 @@ exports.placeholderGrammars = {
23
23
  // see ../../grammar/liquid-html.ohm for full list
24
24
  exports.BLOCKS = exports.strictGrammars.LiquidHTML.rules.blockName.body.factors[0].terms.map((x) => x.obj);
25
25
  // see ../../grammar/liquid-html.ohm for full list
26
- exports.RAW_TAGS = exports.strictGrammars.LiquidHTML.rules.liquidRawTag.body.terms
27
- .map((term) => term.args[0].obj)
28
- .concat('comment');
26
+ exports.RAW_TAGS = (() => {
27
+ const rule = exports.strictGrammars.LiquidHTML.rules.liquidRawTag;
28
+ // When there's only one alternative, body is the Apply node directly (no .terms)
29
+ const terms = rule.body.terms ? rule.body.terms : [rule.body];
30
+ return terms.map((term) => term.args[0].obj).concat('comment');
31
+ })();
29
32
  // see ../../grammar/liquid-html.ohm for full list
30
33
  exports.VOID_ELEMENTS = exports.strictGrammars.LiquidHTML.rules.voidElementName.body.factors[0].terms.map((x) => x.args[0].obj);
31
- exports.TAGS_WITHOUT_MARKUP = [
32
- 'style',
33
- 'schema',
34
- 'javascript',
35
- 'else',
36
- 'break',
37
- 'continue',
38
- 'comment',
39
- 'raw',
40
- 'doc',
41
- ];
34
+ exports.TAGS_WITHOUT_MARKUP = ['else', 'break', 'continue', 'comment', 'raw', 'doc'];
42
35
  //# sourceMappingURL=grammar.js.map
@@ -70,7 +70,6 @@ export declare enum ConcreteNodeTypes {
70
70
  FunctionMarkup = "FunctionMarkup",
71
71
  GraphQLMarkup = "GraphQLMarkup",
72
72
  GraphQLInlineMarkup = "GraphQLInlineMarkup",
73
- PaginateMarkup = "PaginateMarkup",
74
73
  RenderVariableExpression = "RenderVariableExpression",
75
74
  RenderAliasExpression = "RenderAliasExpression",
76
75
  ContentForNamedArgument = "ContentForNamedArgument",
@@ -79,6 +78,9 @@ export declare enum ConcreteNodeTypes {
79
78
  LiquidDocDescriptionNode = "LiquidDocDescriptionNode",
80
79
  LiquidDocExampleNode = "LiquidDocExampleNode",
81
80
  LiquidDocPromptNode = "LiquidDocPromptNode",
81
+ JsonHashLiteral = "JsonHashLiteral",
82
+ JsonArrayLiteral = "JsonArrayLiteral",
83
+ JsonKeyValuePair = "JsonKeyValuePair",
82
84
  BackgroundMarkup = "BackgroundMarkup",
83
85
  BackgroundInlineMarkup = "BackgroundInlineMarkup",
84
86
  CacheMarkup = "CacheMarkup",
@@ -194,7 +196,7 @@ export interface ConcreteLiquidRawTag extends ConcreteBasicLiquidNode<ConcreteNo
194
196
  blockEndLocEnd: number;
195
197
  }
196
198
  export type ConcreteLiquidTagOpen = ConcreteLiquidTagOpenBaseCase | ConcreteLiquidTagOpenNamed;
197
- export type ConcreteLiquidTagOpenNamed = ConcreteLiquidTagOpenCase | ConcreteLiquidTagOpenCapture | ConcreteLiquidTagOpenGraphQL | ConcreteLiquidTagOpenIf | ConcreteLiquidTagOpenUnless | ConcreteLiquidTagOpenForm | ConcreteLiquidTagOpenFor | ConcreteLiquidTagOpenPaginate | ConcreteLiquidTagOpenTablerow | ConcreteLiquidTagOpenBackground | ConcreteLiquidTagOpenCache | ConcreteLiquidTagOpenParseJson | ConcreteLiquidTagOpenTransaction | ConcreteLiquidTagOpenTry;
199
+ export type ConcreteLiquidTagOpenNamed = ConcreteLiquidTagOpenCase | ConcreteLiquidTagOpenCapture | ConcreteLiquidTagOpenGraphQL | ConcreteLiquidTagOpenIf | ConcreteLiquidTagOpenUnless | ConcreteLiquidTagOpenForm | ConcreteLiquidTagOpenFor | ConcreteLiquidTagOpenTablerow | ConcreteLiquidTagOpenBackground | ConcreteLiquidTagOpenCache | ConcreteLiquidTagOpenContentFor | ConcreteLiquidTagOpenParseJson | ConcreteLiquidTagOpenTransaction | ConcreteLiquidTagOpenTry;
198
200
  export interface ConcreteLiquidTagOpenNode<Name, Markup> extends ConcreteBasicLiquidNode<ConcreteNodeTypes.LiquidTagOpen> {
199
201
  name: Name;
200
202
  markup: Markup;
@@ -236,18 +238,11 @@ export interface ConcreteLiquidTagForMarkup extends ConcreteBasicNode<ConcreteNo
236
238
  }
237
239
  export interface ConcreteLiquidTagOpenTablerow extends ConcreteLiquidTagOpenNode<NamedTags.tablerow, ConcreteLiquidTagForMarkup> {
238
240
  }
239
- export interface ConcreteLiquidTagOpenPaginate extends ConcreteLiquidTagOpenNode<NamedTags.paginate, ConcretePaginateMarkup> {
240
- }
241
- export interface ConcretePaginateMarkup extends ConcreteBasicNode<ConcreteNodeTypes.PaginateMarkup> {
242
- collection: ConcreteLiquidExpression;
243
- pageSize: ConcreteLiquidExpression;
244
- args: ConcreteLiquidNamedArgument[] | null;
245
- }
246
241
  export interface ConcreteLiquidTagClose extends ConcreteBasicLiquidNode<ConcreteNodeTypes.LiquidTagClose> {
247
242
  name: string;
248
243
  }
249
244
  export type ConcreteLiquidTag = ConcreteLiquidTagNamed | ConcreteLiquidTagBaseCase;
250
- export type ConcreteLiquidTagNamed = ConcreteLiquidTagAssign | ConcreteLiquidTagHashAssign | ConcreteLiquidTagCycle | ConcreteLiquidTagContentFor | ConcreteLiquidTagEcho | ConcreteLiquidTagIncrement | ConcreteLiquidTagDecrement | ConcreteLiquidTagElsif | ConcreteLiquidTagInclude | ConcreteLiquidTagLayout | ConcreteLiquidTagLiquid | ConcreteLiquidTagRender | ConcreteLiquidTagFunction | ConcreteLiquidTagGraphQL | ConcreteLiquidTagSection | ConcreteLiquidTagSections | ConcreteLiquidTagWhen | ConcreteLiquidTagBackground | ConcreteLiquidTagCatch | ConcreteLiquidTagContext | ConcreteLiquidTagExport | ConcreteLiquidTagIncludeForm | ConcreteLiquidTagLog | ConcreteLiquidTagPrint | ConcreteLiquidTagRedirectTo | ConcreteLiquidTagResponseHeaders | ConcreteLiquidTagResponseStatus | ConcreteLiquidTagReturn | ConcreteLiquidTagRollback | ConcreteLiquidTagSession | ConcreteLiquidTagSignIn | ConcreteLiquidTagSpamProtection | ConcreteLiquidTagThemeRenderRc | ConcreteLiquidTagYield;
245
+ export type ConcreteLiquidTagNamed = ConcreteLiquidTagAssign | ConcreteLiquidTagHashAssign | ConcreteLiquidTagCycle | ConcreteLiquidTagEcho | ConcreteLiquidTagIncrement | ConcreteLiquidTagDecrement | ConcreteLiquidTagElsif | ConcreteLiquidTagInclude | ConcreteLiquidTagLayout | ConcreteLiquidTagLiquid | ConcreteLiquidTagRender | ConcreteLiquidTagFunction | ConcreteLiquidTagGraphQL | ConcreteLiquidTagWhen | ConcreteLiquidTagBackground | ConcreteLiquidTagCatch | ConcreteLiquidTagContext | ConcreteLiquidTagExport | ConcreteLiquidTagIncludeForm | ConcreteLiquidTagLog | ConcreteLiquidTagPrint | ConcreteLiquidTagRedirectTo | ConcreteLiquidTagResponseHeaders | ConcreteLiquidTagResponseStatus | ConcreteLiquidTagReturn | ConcreteLiquidTagRollback | ConcreteLiquidTagSession | ConcreteLiquidTagSignIn | ConcreteLiquidTagSpamProtection | ConcreteLiquidTagThemeRenderRc | ConcreteLiquidTagYield;
251
246
  export interface ConcreteLiquidTagNode<Name, Markup> extends ConcreteBasicLiquidNode<ConcreteNodeTypes.LiquidTag> {
252
247
  markup: Markup;
253
248
  name: Name;
@@ -260,10 +255,6 @@ export interface ConcreteLiquidTagIncrement extends ConcreteLiquidTagNode<NamedT
260
255
  }
261
256
  export interface ConcreteLiquidTagDecrement extends ConcreteLiquidTagNode<NamedTags.decrement, ConcreteLiquidVariableLookup> {
262
257
  }
263
- export interface ConcreteLiquidTagSection extends ConcreteLiquidTagNode<NamedTags.section, ConcreteStringLiteral> {
264
- }
265
- export interface ConcreteLiquidTagSections extends ConcreteLiquidTagNode<NamedTags.sections, ConcreteStringLiteral> {
266
- }
267
258
  export interface ConcreteLiquidTagLayout extends ConcreteLiquidTagNode<NamedTags.layout, ConcreteLiquidExpression> {
268
259
  }
269
260
  export interface ConcreteLiquidTagLiquid extends ConcreteLiquidTagNode<NamedTags.liquid, ConcreteLiquidLiquidTagNode[]> {
@@ -273,6 +264,8 @@ export interface ConcreteLiquidTagAssign extends ConcreteLiquidTagNode<NamedTags
273
264
  }
274
265
  export interface ConcreteLiquidTagAssignMarkup extends ConcreteBasicNode<ConcreteNodeTypes.AssignMarkup> {
275
266
  name: string;
267
+ target: ConcreteLiquidVariableLookup;
268
+ operator: string;
276
269
  value: ConcreteLiquidVariable;
277
270
  }
278
271
  export interface ConcreteLiquidTagHashAssign extends ConcreteLiquidTagNode<NamedTags.hash_assign, ConcreteLiquidTagHashAssignMarkup> {
@@ -287,7 +280,7 @@ export interface ConcreteLiquidTagCycleMarkup extends ConcreteBasicNode<Concrete
287
280
  groupName: ConcreteLiquidExpression | null;
288
281
  args: ConcreteLiquidExpression[];
289
282
  }
290
- export interface ConcreteLiquidTagContentFor extends ConcreteLiquidTagNode<NamedTags.content_for, ConcreteLiquidTagContentForMarkup> {
283
+ export interface ConcreteLiquidTagOpenContentFor extends ConcreteLiquidTagOpenNode<NamedTags.content_for, ConcreteLiquidTagContentForMarkup> {
291
284
  }
292
285
  export interface ConcreteLiquidTagRender extends ConcreteLiquidTagNode<NamedTags.render, ConcreteLiquidTagRenderMarkup> {
293
286
  }
@@ -343,7 +336,6 @@ export interface ConcreteLiquidTagOpenTry extends ConcreteLiquidTagOpenNode<Name
343
336
  }
344
337
  export interface ConcreteLiquidTagContentForMarkup extends ConcreteBasicNode<ConcreteNodeTypes.ContentForMarkup> {
345
338
  contentForType: ConcreteStringLiteral;
346
- args: ConcreteLiquidNamedArgument[];
347
339
  }
348
340
  export interface ConcreteLiquidTagRenderMarkup extends ConcreteBasicNode<ConcreteNodeTypes.RenderMarkup> {
349
341
  snippet: ConcreteStringLiteral | ConcreteLiquidVariableLookup;
@@ -426,7 +418,7 @@ export interface ConcreteLiquidNamedArgument extends ConcreteBasicNode<ConcreteN
426
418
  name: string;
427
419
  value: ConcreteLiquidExpression;
428
420
  }
429
- export type ConcreteLiquidExpression = ConcreteStringLiteral | ConcreteNumberLiteral | ConcreteLiquidLiteral | ConcreteLiquidRange | ConcreteLiquidVariableLookup;
421
+ export type ConcreteLiquidExpression = ConcreteStringLiteral | ConcreteNumberLiteral | ConcreteLiquidLiteral | ConcreteLiquidRange | ConcreteLiquidVariableLookup | ConcreteJsonHashLiteral | ConcreteJsonArrayLiteral;
430
422
  export type ConcreteComplexLiquidExpression = ConcreteLiquidBooleanExpression | ConcreteLiquidExpression;
431
423
  export interface ConcreteLiquidBooleanExpression extends ConcreteBasicNode<ConcreteNodeTypes.BooleanExpression> {
432
424
  conditions: ConcreteLiquidCondition[];
@@ -450,6 +442,17 @@ export interface ConcreteLiquidVariableLookup extends ConcreteBasicNode<Concrete
450
442
  name: string | null;
451
443
  lookups: ConcreteLiquidExpression[];
452
444
  }
445
+ export interface ConcreteJsonHashLiteral extends ConcreteBasicNode<ConcreteNodeTypes.JsonHashLiteral> {
446
+ entries: ConcreteJsonKeyValuePair[];
447
+ }
448
+ export interface ConcreteJsonKeyValuePair extends ConcreteBasicNode<ConcreteNodeTypes.JsonKeyValuePair> {
449
+ key: ConcreteLiquidExpression;
450
+ value: ConcreteJsonValue;
451
+ }
452
+ export interface ConcreteJsonArrayLiteral extends ConcreteBasicNode<ConcreteNodeTypes.JsonArrayLiteral> {
453
+ elements: ConcreteJsonValue[];
454
+ }
455
+ export type ConcreteJsonValue = ConcreteJsonHashLiteral | ConcreteJsonArrayLiteral | ConcreteLiquidExpression;
453
456
  export type ConcreteHtmlNode = ConcreteHtmlDoctype | ConcreteHtmlComment | ConcreteHtmlRawTag | ConcreteHtmlVoidElement | ConcreteHtmlSelfClosingElement | ConcreteHtmlTagOpen | ConcreteHtmlTagClose;
454
457
  export interface ConcreteTextNode extends ConcreteBasicNode<ConcreteNodeTypes.TextNode> {
455
458
  value: string;
@@ -78,7 +78,6 @@ var ConcreteNodeTypes;
78
78
  ConcreteNodeTypes["FunctionMarkup"] = "FunctionMarkup";
79
79
  ConcreteNodeTypes["GraphQLMarkup"] = "GraphQLMarkup";
80
80
  ConcreteNodeTypes["GraphQLInlineMarkup"] = "GraphQLInlineMarkup";
81
- ConcreteNodeTypes["PaginateMarkup"] = "PaginateMarkup";
82
81
  ConcreteNodeTypes["RenderVariableExpression"] = "RenderVariableExpression";
83
82
  ConcreteNodeTypes["RenderAliasExpression"] = "RenderAliasExpression";
84
83
  ConcreteNodeTypes["ContentForNamedArgument"] = "ContentForNamedArgument";
@@ -87,6 +86,9 @@ var ConcreteNodeTypes;
87
86
  ConcreteNodeTypes["LiquidDocDescriptionNode"] = "LiquidDocDescriptionNode";
88
87
  ConcreteNodeTypes["LiquidDocExampleNode"] = "LiquidDocExampleNode";
89
88
  ConcreteNodeTypes["LiquidDocPromptNode"] = "LiquidDocPromptNode";
89
+ ConcreteNodeTypes["JsonHashLiteral"] = "JsonHashLiteral";
90
+ ConcreteNodeTypes["JsonArrayLiteral"] = "JsonArrayLiteral";
91
+ ConcreteNodeTypes["JsonKeyValuePair"] = "JsonKeyValuePair";
90
92
  // platformos markup types
91
93
  ConcreteNodeTypes["BackgroundMarkup"] = "BackgroundMarkup";
92
94
  ConcreteNodeTypes["BackgroundInlineMarkup"] = "BackgroundInlineMarkup";
@@ -167,23 +169,9 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
167
169
  name: 3,
168
170
  body: 9,
169
171
  children: (tokens) => {
170
- const nameNode = tokens[3];
172
+ // {% raw %} accepts syntax errors, we shouldn't try to parse that
171
173
  const rawMarkupStringNode = tokens[9];
172
- switch (nameNode.sourceString) {
173
- // {% schema %} parses its content as a string and should not be visited
174
- case 'schema':
175
- // {% raw %} accepts syntax errors, we shouldn't try to parse that
176
- case 'raw': {
177
- return toCST(source, grammars, grammar_1.TextNodeGrammar, ['HelperMappings'], rawMarkupStringNode.sourceString, offset + rawMarkupStringNode.source.startIdx);
178
- }
179
- // {% style %} actually parses its child nodes, so they are part of the AST
180
- // {% javascript %}, {% stylesheet %} don't, but we want to flag folks that
181
- // those are not supported in StaticStylesheetAndJavascriptTags, so we put
182
- // them in the AST
183
- default: {
184
- return toCST(source, grammars, grammars.Liquid, ['HelperMappings', 'LiquidMappings'], rawMarkupStringNode.sourceString, offset + rawMarkupStringNode.source.startIdx);
185
- }
186
- }
174
+ return toCST(source, grammars, grammar_1.TextNodeGrammar, ['HelperMappings'], rawMarkupStringNode.sourceString, offset + rawMarkupStringNode.source.startIdx);
187
175
  },
188
176
  markup: 6,
189
177
  whitespaceStart: 1,
@@ -285,16 +273,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
285
273
  liquidTagBreak: 0,
286
274
  liquidTagContinue: 0,
287
275
  liquidTagOpenTablerow: 0,
288
- liquidTagOpenPaginate: 0,
289
- liquidTagOpenPaginateMarkup: {
290
- type: ConcreteNodeTypes.PaginateMarkup,
291
- collection: 0,
292
- pageSize: 4,
293
- args: 6,
294
- locStart,
295
- locEnd,
296
- source,
297
- },
298
276
  liquidTagOpenCase: 0,
299
277
  liquidTagOpenCaseMarkup: 0,
300
278
  liquidTagWhen: 0,
@@ -344,8 +322,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
344
322
  liquidTagFunction: 0,
345
323
  liquidTagGraphQL: 0,
346
324
  liquidTagInclude: 0,
347
- liquidTagSection: 0,
348
- liquidTagSections: 0,
349
325
  liquidTagLayout: 0,
350
326
  liquidTagRule: {
351
327
  type: ConcreteNodeTypes.LiquidTag,
@@ -369,17 +345,69 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
369
345
  return toCST(source, grammars, grammars.LiquidStatement, ['HelperMappings', 'LiquidMappings', 'LiquidStatement'], tagMarkup.sourceString, offset + tagMarkup.source.startIdx);
370
346
  },
371
347
  liquidTagEchoMarkup: 0,
372
- liquidTagSectionMarkup: 0,
373
- liquidTagSectionsMarkup: 0,
374
348
  liquidTagLayoutMarkup: 0,
375
349
  liquidTagAssignMarkup: {
376
350
  type: ConcreteNodeTypes.AssignMarkup,
351
+ name: (tokens) => tokens[0].children[0].sourceString,
352
+ target: 0,
353
+ operator: 2,
354
+ value: 4,
355
+ locStart,
356
+ locEnd,
357
+ source,
358
+ },
359
+ assignTarget: {
360
+ type: ConcreteNodeTypes.VariableLookup,
377
361
  name: 0,
362
+ lookups: 1,
363
+ locStart,
364
+ locEnd,
365
+ source,
366
+ },
367
+ assignOperator: (node) => node.sourceString,
368
+ liquidAssignVariable: {
369
+ type: ConcreteNodeTypes.LiquidVariable,
370
+ expression: 0,
371
+ filters: 1,
372
+ rawSource: (tokens) => source.slice(locStart(tokens), tokens[tokens.length - 2].source.endIdx).trimEnd(),
373
+ locStart,
374
+ locEnd: locEndSecondToLast,
375
+ source,
376
+ },
377
+ liquidAssignExpression: 0,
378
+ liquidJsonHashLiteral: {
379
+ type: ConcreteNodeTypes.JsonHashLiteral,
380
+ entries: 2,
381
+ locStart,
382
+ locEnd,
383
+ source,
384
+ },
385
+ liquidJsonKeyValue: {
386
+ type: ConcreteNodeTypes.JsonKeyValuePair,
387
+ key: 0,
378
388
  value: 4,
379
389
  locStart,
380
390
  locEnd,
381
391
  source,
382
392
  },
393
+ liquidJsonKey: 0,
394
+ liquidJsonBareKey: {
395
+ type: ConcreteNodeTypes.VariableLookup,
396
+ name: 0,
397
+ lookups: () => [],
398
+ locStart,
399
+ locEnd,
400
+ source,
401
+ },
402
+ liquidJsonArrayLiteral: {
403
+ type: ConcreteNodeTypes.JsonArrayLiteral,
404
+ elements: 2,
405
+ locStart,
406
+ locEnd,
407
+ source,
408
+ },
409
+ liquidJsonValue: 0,
410
+ liquidJsonSep: 1,
383
411
  liquidTagHashAssignMarkup: {
384
412
  type: ConcreteNodeTypes.HashAssignMarkup,
385
413
  target: 0,
@@ -396,10 +424,10 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
396
424
  locEnd,
397
425
  source,
398
426
  },
427
+ liquidTagOpenContentFor: 0,
399
428
  liquidTagContentForMarkup: {
400
429
  type: ConcreteNodeTypes.ContentForMarkup,
401
430
  contentForType: 0,
402
- args: 2,
403
431
  locStart,
404
432
  locEnd,
405
433
  source,
@@ -619,13 +647,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
619
647
  },
620
648
  simpleArgument: 0,
621
649
  tagArguments: 0,
622
- contentForTagArgument: 0,
623
- completionModeContentForTagArgument: function (namedArguments, _separator, variableLookup) {
624
- const self = this;
625
- return namedArguments
626
- .toAST(self.args.mapping)
627
- .concat(variableLookup.sourceString === '' ? [] : variableLookup.toAST(self.args.mapping));
628
- },
629
650
  positionalArgument: 0,
630
651
  namedArgument: {
631
652
  type: ConcreteNodeTypes.NamedArgument,
@@ -635,14 +656,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
635
656
  locEnd,
636
657
  source,
637
658
  },
638
- contentForNamedArgument: {
639
- type: ConcreteNodeTypes.NamedArgument,
640
- name: (node) => node[0].sourceString + node[1].sourceString,
641
- value: 6,
642
- locStart,
643
- locEnd,
644
- source,
645
- },
646
659
  liquidBooleanExpression(initialCondition, subsequentConditions) {
647
660
  const initialConditionAst = initialCondition.toAST(this.args.mapping);
648
661
  const subsequentConditionAsts = subsequentConditions.toAST(this.args.mapping);
@@ -35,7 +35,7 @@
35
35
  import { ConcreteAttributeNode, ConcreteHtmlTagClose, ConcreteLiquidTagClose, LiquidCST, LiquidHtmlCST, ConcreteLiquidLiteral } from './stage-1-cst';
36
36
  import { Comparators, NamedTags, NodeTypes, Position } from './types';
37
37
  /** The union type of all possible node types inside a LiquidHTML AST. */
38
- export type LiquidHtmlNode = DocumentNode | YAMLFrontmatter | LiquidNode | HtmlDoctype | HtmlNode | AttributeNode | LiquidVariable | ComplexLiquidExpression | LiquidFilter | LiquidNamedArgument | AssignMarkup | HashAssignMarkup | ContentForMarkup | CycleMarkup | ForMarkup | RenderMarkup | FunctionMarkup | GraphQLMarkup | GraphQLInlineMarkup | PaginateMarkup | RawMarkup | RenderVariableExpression | RenderAliasExpression | LiquidLogicalExpression | LiquidComparison | TextNode | LiquidDocParamNode | LiquidDocExampleNode | LiquidDocPromptNode | LiquidDocDescriptionNode | BackgroundMarkup | BackgroundInlineMarkup | CacheMarkup | LogMarkup | SessionMarkup | ExportMarkup | RedirectToMarkup | IncludeFormMarkup | SpamProtectionMarkup;
38
+ export type LiquidHtmlNode = DocumentNode | YAMLFrontmatter | LiquidNode | HtmlDoctype | HtmlNode | AttributeNode | LiquidVariable | ComplexLiquidExpression | LiquidFilter | LiquidNamedArgument | AssignMarkup | HashAssignMarkup | ContentForMarkup | CycleMarkup | ForMarkup | RenderMarkup | FunctionMarkup | GraphQLMarkup | GraphQLInlineMarkup | RawMarkup | RenderVariableExpression | RenderAliasExpression | LiquidLogicalExpression | LiquidComparison | TextNode | LiquidDocParamNode | LiquidDocExampleNode | LiquidDocPromptNode | LiquidDocDescriptionNode | JsonHashLiteral | JsonArrayLiteral | JsonKeyValuePair | BackgroundMarkup | BackgroundInlineMarkup | CacheMarkup | LogMarkup | SessionMarkup | ExportMarkup | RedirectToMarkup | IncludeFormMarkup | SpamProtectionMarkup;
39
39
  /** The root node of all LiquidHTML ASTs. */
40
40
  export interface DocumentNode extends ASTNode<NodeTypes.Document> {
41
41
  children: LiquidHtmlNode[];
@@ -96,7 +96,7 @@ export interface LiquidRawTag extends ASTNode<NodeTypes.LiquidRawTag> {
96
96
  /** The union type of strictly typed and loosely typed Liquid tag nodes */
97
97
  export type LiquidTag = LiquidTagNamed | LiquidTagBaseCase;
98
98
  /** The union type of all strictly typed LiquidTag nodes */
99
- export type LiquidTagNamed = LiquidTagAssign | LiquidTagHashAssign | LiquidTagCase | LiquidTagCapture | LiquidTagContentFor | LiquidTagCycle | LiquidTagDecrement | LiquidTagEcho | LiquidTagFor | LiquidTagForm | LiquidTagIf | LiquidTagInclude | LiquidTagIncrement | LiquidTagLayout | LiquidTagLiquid | LiquidTagPaginate | LiquidTagRender | LiquidTagFunction | LiquidTagGraphQL | LiquidTagSection | LiquidTagSections | LiquidTagTablerow | LiquidTagUnless | LiquidTagBackground | LiquidTagCache | LiquidTagContext | LiquidTagExport | LiquidTagIncludeForm | LiquidTagLog | LiquidTagParseJson | LiquidTagPrint | LiquidTagRedirectTo | LiquidTagResponseHeaders | LiquidTagResponseStatus | LiquidTagReturn | LiquidTagRollback | LiquidTagSession | LiquidTagSignIn | LiquidTagSpamProtection | LiquidTagThemeRenderRc | LiquidTagTransaction | LiquidTagTry | LiquidTagYield;
99
+ export type LiquidTagNamed = LiquidTagAssign | LiquidTagHashAssign | LiquidTagCase | LiquidTagCapture | LiquidTagContentFor | LiquidTagCycle | LiquidTagDecrement | LiquidTagEcho | LiquidTagFor | LiquidTagForm | LiquidTagIf | LiquidTagInclude | LiquidTagIncrement | LiquidTagLayout | LiquidTagLiquid | LiquidTagRender | LiquidTagFunction | LiquidTagGraphQL | LiquidTagTablerow | LiquidTagUnless | LiquidTagBackground | LiquidTagCache | LiquidTagContext | LiquidTagExport | LiquidTagIncludeForm | LiquidTagLog | LiquidTagParseJson | LiquidTagPrint | LiquidTagRedirectTo | LiquidTagResponseHeaders | LiquidTagResponseStatus | LiquidTagReturn | LiquidTagRollback | LiquidTagSession | LiquidTagSignIn | LiquidTagSpamProtection | LiquidTagThemeRenderRc | LiquidTagTransaction | LiquidTagTry | LiquidTagYield;
100
100
  export interface LiquidTagNode<Name, Markup> extends ASTNode<NodeTypes.LiquidTag> {
101
101
  /** e.g. if, ifchanged, for, etc. */
102
102
  name: Name;
@@ -137,8 +137,12 @@ export interface LiquidTagAssign extends LiquidTagNode<NamedTags.assign, AssignM
137
137
  }
138
138
  /** {% assign name = value %} */
139
139
  export interface AssignMarkup extends ASTNode<NodeTypes.AssignMarkup> {
140
- /** the name of the variable that is being assigned */
140
+ /** the base variable name (backward compatible) */
141
141
  name: string;
142
+ /** bracket/dot lookups on the target (empty for simple assignment) */
143
+ lookups: LiquidExpression[];
144
+ /** '=' for assignment, '<<' for array append */
145
+ operator: '=' | '<<';
142
146
  /** the value of the variable that is being assigned */
143
147
  value: LiquidVariable;
144
148
  }
@@ -224,19 +228,11 @@ export interface LiquidComparison extends ASTNode<NodeTypes.Comparison> {
224
228
  left: LiquidExpression;
225
229
  right: LiquidExpression;
226
230
  }
227
- /** https://shopify.dev/docs/api/liquid/tags#paginate */
228
- export interface LiquidTagPaginate extends LiquidTagNode<NamedTags.paginate, PaginateMarkup> {
229
- }
230
- /** {% paginate collection by pageSize [...namedArgs] %} */
231
- export interface PaginateMarkup extends ASTNode<NodeTypes.PaginateMarkup> {
232
- /** {% paginate collection by pageSize %} */
233
- collection: LiquidExpression;
234
- /** {% paginate collection by pageSize %} */
235
- pageSize: LiquidExpression;
236
- /** optional named arguments such as `window_size: 10` */
237
- args: LiquidNamedArgument[];
238
- }
239
- /** https://shopify.dev/docs/api/liquid/tags#content_for */
231
+ /**
232
+ * In platformOS, content_for defines a named block of content in a page/partial.
233
+ * Use {% yield 'name' %} in a layout to render it.
234
+ * @example {% content_for 'pagetitle' %}<title>Hello</title>{% endcontent_for %}
235
+ */
240
236
  export interface LiquidTagContentFor extends LiquidTagNode<NamedTags.content_for, ContentForMarkup> {
241
237
  }
242
238
  /** https://shopify.dev/docs/api/liquid/tags#render */
@@ -249,30 +245,15 @@ export interface LiquidTagGraphQL extends LiquidTagNode<NamedTags.graphql, Graph
249
245
  /** https://shopify.dev/docs/api/liquid/tags#include */
250
246
  export interface LiquidTagInclude extends LiquidTagNode<NamedTags.include, RenderMarkup> {
251
247
  }
252
- /** https://shopify.dev/docs/api/liquid/tags#section */
253
- export interface LiquidTagSection extends LiquidTagNode<NamedTags.section, LiquidString> {
254
- }
255
- /** https://shopify.dev/docs/api/liquid/tags#sections */
256
- export interface LiquidTagSections extends LiquidTagNode<NamedTags.sections, LiquidString> {
257
- }
258
248
  /** https://shopify.dev/docs/api/liquid/tags#layout */
259
249
  export interface LiquidTagLayout extends LiquidTagNode<NamedTags.layout, LiquidExpression> {
260
250
  }
261
251
  /** https://shopify.dev/docs/api/liquid/tags#liquid */
262
252
  export interface LiquidTagLiquid extends LiquidTagNode<NamedTags.liquid, LiquidStatement[]> {
263
253
  }
264
- /** {% content_for 'contentForType' [...namedArguments] %} */
254
+ /** {% content_for 'name' %}...{% endcontent_for %} */
265
255
  export interface ContentForMarkup extends ASTNode<NodeTypes.ContentForMarkup> {
266
- /** {% content_for 'contentForType' %} */
267
256
  contentForType: LiquidString;
268
- /**
269
- * WARNING: `args` could contain LiquidVariableLookup when we are in a completion context
270
- * because the NamedArgument isn't fully typed out.
271
- * E.g. {% content_for 'contentForType', arg1: value1, arg2█ %}
272
- *
273
- * @example {% content_for 'contentForType', arg1: value1, arg2: value2 %}
274
- */
275
- args: LiquidNamedArgument[];
276
257
  }
277
258
  /** {% render 'partial' [(with|for) variable [as alias]], [...namedArguments] %} */
278
259
  export interface RenderMarkup extends ASTNode<NodeTypes.RenderMarkup> {
@@ -506,7 +487,7 @@ export interface LiquidVariable extends ASTNode<NodeTypes.LiquidVariable> {
506
487
  rawSource: string;
507
488
  }
508
489
  /** The union type of all Liquid expression nodes */
509
- export type LiquidExpression = LiquidString | LiquidNumber | LiquidLiteral | LiquidRange | LiquidVariableLookup;
490
+ export type LiquidExpression = LiquidString | LiquidNumber | LiquidLiteral | LiquidRange | LiquidVariableLookup | JsonHashLiteral | JsonArrayLiteral;
510
491
  export type ComplexLiquidExpression = LiquidBooleanExpression | LiquidExpression;
511
492
  /** https://shopify.dev/docs/api/liquid/filters */
512
493
  export interface LiquidFilter extends ASTNode<NodeTypes.LiquidFilter> {
@@ -565,6 +546,19 @@ export interface LiquidVariableLookup extends ASTNode<NodeTypes.VariableLookup>
565
546
  /** name.lookup1[lookup2] */
566
547
  lookups: LiquidExpression[];
567
548
  }
549
+ /** Represents a JSON hash literal { key: value, ... } */
550
+ export interface JsonHashLiteral extends ASTNode<NodeTypes.JsonHashLiteral> {
551
+ entries: JsonKeyValuePair[];
552
+ }
553
+ /** Represents a key-value pair in a JSON hash literal */
554
+ export interface JsonKeyValuePair extends ASTNode<NodeTypes.JsonKeyValuePair> {
555
+ key: LiquidExpression;
556
+ value: LiquidExpression;
557
+ }
558
+ /** Represents a JSON array literal [el1, el2, ...] */
559
+ export interface JsonArrayLiteral extends ASTNode<NodeTypes.JsonArrayLiteral> {
560
+ elements: LiquidExpression[];
561
+ }
568
562
  /** The union type of all HTML nodes */
569
563
  export type HtmlNode = HtmlComment | HtmlElement | HtmlDanglingMarkerClose | HtmlVoidElement | HtmlSelfClosingElement | HtmlRawNode;
570
564
  /** The basic HTML node with an opening and closing tags. */
@@ -617,6 +617,7 @@ function toNamedLiquidTag(node, options) {
617
617
  ...liquidTagBaseAttributes(node),
618
618
  name: node.name,
619
619
  markup: toContentForMarkup(node.markup),
620
+ children: [],
620
621
  };
621
622
  }
622
623
  case types_1.NamedTags.include:
@@ -650,15 +651,7 @@ function toNamedLiquidTag(node, options) {
650
651
  markup: toGraphQLMarkup(node.markup),
651
652
  };
652
653
  }
653
- case types_1.NamedTags.layout:
654
- case types_1.NamedTags.section: {
655
- return {
656
- ...liquidTagBaseAttributes(node),
657
- name: node.name,
658
- markup: toExpression(node.markup),
659
- };
660
- }
661
- case types_1.NamedTags.sections: {
654
+ case types_1.NamedTags.layout: {
662
655
  return {
663
656
  ...liquidTagBaseAttributes(node),
664
657
  name: node.name,
@@ -682,14 +675,6 @@ function toNamedLiquidTag(node, options) {
682
675
  children: [],
683
676
  };
684
677
  }
685
- case types_1.NamedTags.paginate: {
686
- return {
687
- ...liquidTagBaseAttributes(node),
688
- name: node.name,
689
- markup: toPaginateMarkup(node.markup),
690
- children: [],
691
- };
692
- }
693
678
  case types_1.NamedTags.if:
694
679
  case types_1.NamedTags.unless: {
695
680
  return {
@@ -916,6 +901,8 @@ function toAssignMarkup(node) {
916
901
  return {
917
902
  type: types_1.NodeTypes.AssignMarkup,
918
903
  name: node.name,
904
+ lookups: node.target.lookups.map(toExpression),
905
+ operator: node.operator,
919
906
  value: toLiquidVariable(node.value),
920
907
  position: position(node),
921
908
  source: node.source,
@@ -950,16 +937,6 @@ function toForMarkup(node) {
950
937
  source: node.source,
951
938
  };
952
939
  }
953
- function toPaginateMarkup(node) {
954
- return {
955
- type: types_1.NodeTypes.PaginateMarkup,
956
- collection: toExpression(node.collection),
957
- pageSize: toExpression(node.pageSize),
958
- position: position(node),
959
- args: node.args ? node.args.map(toNamedArgument) : [],
960
- source: node.source,
961
- };
962
- }
963
940
  function toRawMarkup(node, options) {
964
941
  return {
965
942
  type: types_1.NodeTypes.RawMarkup,
@@ -1023,35 +1000,13 @@ function toRawMarkupKindFromHtmlNode(node) {
1023
1000
  return RawMarkupKinds.text;
1024
1001
  }
1025
1002
  }
1026
- function toRawMarkupKindFromLiquidNode(node) {
1027
- switch (node.name) {
1028
- case 'javascript':
1029
- return RawMarkupKinds.javascript;
1030
- case 'stylesheet':
1031
- case 'style':
1032
- if (liquidToken.test(node.body)) {
1033
- return RawMarkupKinds.text;
1034
- }
1035
- return RawMarkupKinds.css;
1036
- case 'schema':
1037
- return RawMarkupKinds.json;
1038
- default:
1039
- return RawMarkupKinds.text;
1040
- }
1003
+ function toRawMarkupKindFromLiquidNode(_node) {
1004
+ return RawMarkupKinds.text;
1041
1005
  }
1042
1006
  function toContentForMarkup(node) {
1043
1007
  return {
1044
1008
  type: types_1.NodeTypes.ContentForMarkup,
1045
1009
  contentForType: toExpression(node.contentForType),
1046
- /**
1047
- * When we're in completion mode we won't necessarily have valid named
1048
- * arguments so we need to call toLiquidArgument instead of toNamedArgument.
1049
- * We cast using `as` so that this doesn't affect the type system used in
1050
- * other areas (like theme check) for a scenario that only occurs in
1051
- * completion mode. This means that our types are *wrong* in completion mode
1052
- * but this is the compromise we're making to get completions to work.
1053
- */
1054
- args: node.args.map(toLiquidArgument),
1055
1010
  position: position(node),
1056
1011
  source: node.source,
1057
1012
  };
@@ -1350,11 +1305,36 @@ function toExpression(node) {
1350
1305
  source: node.source,
1351
1306
  };
1352
1307
  }
1308
+ case stage_1_cst_1.ConcreteNodeTypes.JsonHashLiteral: {
1309
+ return {
1310
+ type: types_1.NodeTypes.JsonHashLiteral,
1311
+ entries: node.entries.map(toJsonKeyValuePair),
1312
+ position: position(node),
1313
+ source: node.source,
1314
+ };
1315
+ }
1316
+ case stage_1_cst_1.ConcreteNodeTypes.JsonArrayLiteral: {
1317
+ return {
1318
+ type: types_1.NodeTypes.JsonArrayLiteral,
1319
+ elements: node.elements.map(toExpression),
1320
+ position: position(node),
1321
+ source: node.source,
1322
+ };
1323
+ }
1353
1324
  default: {
1354
1325
  return (0, utils_1.assertNever)(node);
1355
1326
  }
1356
1327
  }
1357
1328
  }
1329
+ function toJsonKeyValuePair(node) {
1330
+ return {
1331
+ type: types_1.NodeTypes.JsonKeyValuePair,
1332
+ key: toExpression(node.key),
1333
+ value: toExpression(node.value),
1334
+ position: position(node),
1335
+ source: node.source,
1336
+ };
1337
+ }
1358
1338
  function toFilter(node) {
1359
1339
  return {
1360
1340
  type: types_1.NodeTypes.LiquidFilter,
package/dist/types.d.ts CHANGED
@@ -39,7 +39,6 @@ export declare enum NodeTypes {
39
39
  ContentForMarkup = "ContentForMarkup",
40
40
  CycleMarkup = "CycleMarkup",
41
41
  ForMarkup = "ForMarkup",
42
- PaginateMarkup = "PaginateMarkup",
43
42
  RawMarkup = "RawMarkup",
44
43
  RenderMarkup = "RenderMarkup",
45
44
  FunctionMarkup = "FunctionMarkup",
@@ -51,6 +50,9 @@ export declare enum NodeTypes {
51
50
  LiquidDocParamNode = "LiquidDocParamNode",
52
51
  LiquidDocExampleNode = "LiquidDocExampleNode",
53
52
  LiquidDocPromptNode = "LiquidDocPromptNode",
53
+ JsonHashLiteral = "JsonHashLiteral",
54
+ JsonArrayLiteral = "JsonArrayLiteral",
55
+ JsonKeyValuePair = "JsonKeyValuePair",
54
56
  BackgroundMarkup = "BackgroundMarkup",
55
57
  BackgroundInlineMarkup = "BackgroundInlineMarkup",
56
58
  CacheMarkup = "CacheMarkup",
@@ -78,12 +80,9 @@ export declare enum NamedTags {
78
80
  increment = "increment",
79
81
  layout = "layout",
80
82
  liquid = "liquid",
81
- paginate = "paginate",
82
83
  render = "render",
83
84
  function = "function",
84
85
  graphql = "graphql",
85
- section = "section",
86
- sections = "sections",
87
86
  tablerow = "tablerow",
88
87
  unless = "unless",
89
88
  when = "when",
package/dist/types.js CHANGED
@@ -37,7 +37,6 @@ var NodeTypes;
37
37
  NodeTypes["ContentForMarkup"] = "ContentForMarkup";
38
38
  NodeTypes["CycleMarkup"] = "CycleMarkup";
39
39
  NodeTypes["ForMarkup"] = "ForMarkup";
40
- NodeTypes["PaginateMarkup"] = "PaginateMarkup";
41
40
  NodeTypes["RawMarkup"] = "RawMarkup";
42
41
  NodeTypes["RenderMarkup"] = "RenderMarkup";
43
42
  NodeTypes["FunctionMarkup"] = "FunctionMarkup";
@@ -49,6 +48,9 @@ var NodeTypes;
49
48
  NodeTypes["LiquidDocParamNode"] = "LiquidDocParamNode";
50
49
  NodeTypes["LiquidDocExampleNode"] = "LiquidDocExampleNode";
51
50
  NodeTypes["LiquidDocPromptNode"] = "LiquidDocPromptNode";
51
+ NodeTypes["JsonHashLiteral"] = "JsonHashLiteral";
52
+ NodeTypes["JsonArrayLiteral"] = "JsonArrayLiteral";
53
+ NodeTypes["JsonKeyValuePair"] = "JsonKeyValuePair";
52
54
  // platformos markup types
53
55
  NodeTypes["BackgroundMarkup"] = "BackgroundMarkup";
54
56
  NodeTypes["BackgroundInlineMarkup"] = "BackgroundInlineMarkup";
@@ -79,12 +81,9 @@ var NamedTags;
79
81
  NamedTags["increment"] = "increment";
80
82
  NamedTags["layout"] = "layout";
81
83
  NamedTags["liquid"] = "liquid";
82
- NamedTags["paginate"] = "paginate";
83
84
  NamedTags["render"] = "render";
84
85
  NamedTags["function"] = "function";
85
86
  NamedTags["graphql"] = "graphql";
86
- NamedTags["section"] = "section";
87
- NamedTags["sections"] = "sections";
88
87
  NamedTags["tablerow"] = "tablerow";
89
88
  NamedTags["unless"] = "unless";
90
89
  NamedTags["when"] = "when";
@@ -52,7 +52,6 @@ Liquid <: Helpers {
52
52
  | liquidTagBreak
53
53
  | liquidTagContinue
54
54
  | liquidTagCycle
55
- | liquidTagContentFor
56
55
  | liquidTagDecrement
57
56
  | liquidTagEcho
58
57
  | liquidTagElse
@@ -64,8 +63,6 @@ Liquid <: Helpers {
64
63
  | liquidTagRender
65
64
  | liquidTagFunction
66
65
  | liquidTagGraphQL
67
- | liquidTagSection
68
- | liquidTagSections
69
66
  | liquidTagWhen
70
67
  // platformos tags
71
68
  | liquidTagBackground
@@ -98,11 +95,11 @@ Liquid <: Helpers {
98
95
  | liquidTagOpenGraphQL
99
96
  | liquidTagOpenTablerow
100
97
  | liquidTagOpenIf
101
- | liquidTagOpenPaginate
102
98
  | liquidTagOpenUnless
103
99
  // platformos block tags
104
100
  | liquidTagOpenBackground
105
101
  | liquidTagOpenCache
102
+ | liquidTagOpenContentFor
106
103
  | liquidTagOpenParseJson
107
104
  | liquidTagOpenTransaction
108
105
  | liquidTagOpenTry
@@ -129,7 +126,33 @@ Liquid <: Helpers {
129
126
  liquidTagEchoMarkup = liquidVariable<delimTag>
130
127
 
131
128
  liquidTagAssign = liquidTagRule<"assign", liquidTagAssignMarkup>
132
- liquidTagAssignMarkup = variableSegment space* "=" space* liquidVariable<delimTag>
129
+ liquidTagAssignMarkup = assignTarget<delimTag> space* assignOperator space* liquidAssignVariable<delimTag>
130
+
131
+ // Assign-specific sub-rules
132
+ assignTarget<delim> = variableSegment lookup<delim>*
133
+ assignOperator = "<<" | "="
134
+
135
+ // Assign variable: like liquidVariable but expression allows JSON literals
136
+ liquidAssignVariable<delim> = liquidAssignExpression<delim> liquidFilter<delim>* space* &delim
137
+ liquidAssignExpression<delim> =
138
+ | liquidJsonHashLiteral<delim>
139
+ | liquidJsonArrayLiteral<delim>
140
+ | liquidComplexExpression<delim>
141
+
142
+ // JSON literal rules (assign-only, recursive)
143
+ liquidJsonHashLiteral<delim> =
144
+ "{" space* listOf<liquidJsonKeyValue<delim>, liquidJsonSep> space* "}"
145
+ liquidJsonKeyValue<delim> =
146
+ liquidJsonKey<delim> space* ":" space* liquidJsonValue<delim>
147
+ liquidJsonKey<delim> = liquidString<delim> | liquidJsonBareKey
148
+ liquidJsonBareKey = variableSegment
149
+ liquidJsonArrayLiteral<delim> =
150
+ "[" space* listOf<liquidJsonValue<delim>, liquidJsonSep> space* "]"
151
+ liquidJsonValue<delim> =
152
+ | liquidJsonHashLiteral<delim>
153
+ | liquidJsonArrayLiteral<delim>
154
+ | liquidExpression<delim>
155
+ liquidJsonSep = space* "," space*
133
156
 
134
157
  liquidTagHashAssign = liquidTagRule<"hash_assign", liquidTagHashAssignMarkup>
135
158
  liquidTagHashAssignMarkup = liquidVariableLookup<delimTag> space* "=" space* liquidVariable<delimTag>
@@ -142,12 +165,6 @@ Liquid <: Helpers {
142
165
  liquidTagOpenCapture = liquidTagOpenRule<"capture", variableSegmentAsLookupMarkup>
143
166
  variableSegmentAsLookupMarkup = variableSegmentAsLookup space*
144
167
 
145
- liquidTagSection = liquidTagRule<"section", liquidTagSectionMarkup>
146
- liquidTagSectionMarkup = liquidString<delimTag> space*
147
-
148
- liquidTagSections = liquidTagRule<"sections", liquidTagSectionsMarkup>
149
- liquidTagSectionsMarkup = liquidString<delimTag> space*
150
-
151
168
  liquidTagLayout = liquidTagRule<"layout", liquidTagLayoutMarkup>
152
169
  liquidTagLayoutMarkup = liquidExpression<delimTag> space*
153
170
 
@@ -162,15 +179,8 @@ Liquid <: Helpers {
162
179
  liquidTagLiquid = liquidTagRule<"liquid", liquidTagLiquidMarkup>
163
180
  liquidTagLiquidMarkup = tagMarkup
164
181
 
165
- liquidTagContentFor = liquidTagRule<"content_for", liquidTagContentForMarkup>
166
-
167
- liquidTagContentForMarkup =
168
- contentForType (argumentSeparatorOptionalComma contentForTagArgument) (space* ",")? space*
169
-
170
- contentForTagArgument = listOf<contentForNamedArgument<delimTag>, argumentSeparatorOptionalComma>
171
- completionModeContentForTagArgument = listOf<contentForNamedArgument<delimTag>, argumentSeparatorOptionalComma> (argumentSeparator? (liquidVariableLookup<delimTag>))?
172
- contentForNamedArgument<delim> = (variableSegment ("." variableSegment)*) space* ":" space* (liquidExpression<delim>)
173
-
182
+ liquidTagOpenContentFor = liquidTagOpenRule<"content_for", liquidTagContentForMarkup>
183
+ liquidTagContentForMarkup = contentForType space*
174
184
  contentForType = liquidString<delimTag>
175
185
 
176
186
  liquidTagInclude = liquidTagRule<"include", liquidTagRenderMarkup>
@@ -259,7 +269,6 @@ Liquid <: Helpers {
259
269
  liquidTagOpenBaseCase = liquidTagOpenRule<blockNameNotSpecial, tagMarkup>
260
270
  blockNameNotSpecial =
261
271
  ( "form"
262
- | "paginate"
263
272
  | "capture"
264
273
  | "case"
265
274
  | "for"
@@ -278,6 +287,7 @@ Liquid <: Helpers {
278
287
  liquidTagOpenFormMarkup = arguments<delimTag> (space* ",")? space*
279
288
 
280
289
  liquidTagOpenFor = liquidTagOpenRule<"for", liquidTagOpenForMarkup>
290
+
281
291
  liquidTagOpenForMarkup =
282
292
  variableSegment space* "in" space* liquidExpression<delimTag>
283
293
  (space* "reversed")? argumentSeparatorOptionalComma
@@ -315,10 +325,6 @@ Liquid <: Helpers {
315
325
  | "<")
316
326
  | ("contains" ~identifier)
317
327
 
318
- liquidTagOpenPaginate = liquidTagOpenRule<"paginate", liquidTagOpenPaginateMarkup>
319
- liquidTagOpenPaginateMarkup =
320
- liquidExpression<delimTag> space+ "by" space+ liquidExpression<delimTag> argumentSeparatorOptionalComma tagArguments (space* ",")? space*
321
-
322
328
  liquidDrop = "{{" "-"? space* liquidDropCases "-"? "}}"
323
329
  liquidDropCases = liquidVariable<delimVO> | liquidDropBaseCase
324
330
  liquidDropBaseCase = anyExceptStar<delimVO>
@@ -326,10 +332,6 @@ Liquid <: Helpers {
326
332
 
327
333
  liquidRawTag =
328
334
  | liquidRawTagImpl<"raw">
329
- | liquidRawTagImpl<"javascript">
330
- | liquidRawTagImpl<"schema">
331
- | liquidRawTagImpl<"stylesheet">
332
- | liquidRawTagImpl<"style">
333
335
  liquidRawTagImpl<name> =
334
336
  "{%" "-"? space* (name endOfIdentifier) space* tagMarkup "-"? "%}"
335
337
  anyExceptStar<liquidRawTagClose<name>>
@@ -434,9 +436,7 @@ Liquid <: Helpers {
434
436
  letter (alnum | "_")*
435
437
 
436
438
  blockName =
437
- // Shopify blocks
438
439
  ( "form"
439
- | "paginate"
440
440
  // Base blocks
441
441
  | "capture"
442
442
  | "case"
@@ -449,6 +449,7 @@ Liquid <: Helpers {
449
449
  // platformos blocks
450
450
  | "background"
451
451
  | "cache"
452
+ | "content_for"
452
453
  | "parse_json"
453
454
  | "transaction"
454
455
  | "try"
@@ -707,8 +708,6 @@ StrictLiquidHTML <: LiquidHTML {
707
708
 
708
709
  WithPlaceholderLiquid <: Liquid {
709
710
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
710
- liquidTagContentForMarkup :=
711
- contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
712
711
  liquidTagRenderMarkup :=
713
712
  snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
714
713
  liquidTagName := (letter | "█") (alnum | "_")*
@@ -721,8 +720,6 @@ WithPlaceholderLiquid <: Liquid {
721
720
 
722
721
  WithPlaceholderLiquidStatement <: LiquidStatement {
723
722
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
724
- liquidTagContentForMarkup :=
725
- contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
726
723
  liquidTagRenderMarkup :=
727
724
  snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
728
725
  liquidTagName := (letter | "█") (alnum | "_")*
@@ -735,8 +732,6 @@ WithPlaceholderLiquidStatement <: LiquidStatement {
735
732
 
736
733
  WithPlaceholderLiquidHTML <: LiquidHTML {
737
734
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
738
- liquidTagContentForMarkup :=
739
- contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
740
735
  liquidTagRenderMarkup :=
741
736
  snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
742
737
  liquidTagName := (letter | "█") (alnum | "_")*
@@ -52,7 +52,6 @@ Liquid <: Helpers {
52
52
  | liquidTagBreak
53
53
  | liquidTagContinue
54
54
  | liquidTagCycle
55
- | liquidTagContentFor
56
55
  | liquidTagDecrement
57
56
  | liquidTagEcho
58
57
  | liquidTagElse
@@ -64,8 +63,6 @@ Liquid <: Helpers {
64
63
  | liquidTagRender
65
64
  | liquidTagFunction
66
65
  | liquidTagGraphQL
67
- | liquidTagSection
68
- | liquidTagSections
69
66
  | liquidTagWhen
70
67
  // platformos tags
71
68
  | liquidTagBackground
@@ -98,11 +95,11 @@ Liquid <: Helpers {
98
95
  | liquidTagOpenGraphQL
99
96
  | liquidTagOpenTablerow
100
97
  | liquidTagOpenIf
101
- | liquidTagOpenPaginate
102
98
  | liquidTagOpenUnless
103
99
  // platformos block tags
104
100
  | liquidTagOpenBackground
105
101
  | liquidTagOpenCache
102
+ | liquidTagOpenContentFor
106
103
  | liquidTagOpenParseJson
107
104
  | liquidTagOpenTransaction
108
105
  | liquidTagOpenTry
@@ -129,7 +126,33 @@ Liquid <: Helpers {
129
126
  liquidTagEchoMarkup = liquidVariable<delimTag>
130
127
 
131
128
  liquidTagAssign = liquidTagRule<"assign", liquidTagAssignMarkup>
132
- liquidTagAssignMarkup = variableSegment space* "=" space* liquidVariable<delimTag>
129
+ liquidTagAssignMarkup = assignTarget<delimTag> space* assignOperator space* liquidAssignVariable<delimTag>
130
+
131
+ // Assign-specific sub-rules
132
+ assignTarget<delim> = variableSegment lookup<delim>*
133
+ assignOperator = "<<" | "="
134
+
135
+ // Assign variable: like liquidVariable but expression allows JSON literals
136
+ liquidAssignVariable<delim> = liquidAssignExpression<delim> liquidFilter<delim>* space* &delim
137
+ liquidAssignExpression<delim> =
138
+ | liquidJsonHashLiteral<delim>
139
+ | liquidJsonArrayLiteral<delim>
140
+ | liquidComplexExpression<delim>
141
+
142
+ // JSON literal rules (assign-only, recursive)
143
+ liquidJsonHashLiteral<delim> =
144
+ "{" space* listOf<liquidJsonKeyValue<delim>, liquidJsonSep> space* "}"
145
+ liquidJsonKeyValue<delim> =
146
+ liquidJsonKey<delim> space* ":" space* liquidJsonValue<delim>
147
+ liquidJsonKey<delim> = liquidString<delim> | liquidJsonBareKey
148
+ liquidJsonBareKey = variableSegment
149
+ liquidJsonArrayLiteral<delim> =
150
+ "[" space* listOf<liquidJsonValue<delim>, liquidJsonSep> space* "]"
151
+ liquidJsonValue<delim> =
152
+ | liquidJsonHashLiteral<delim>
153
+ | liquidJsonArrayLiteral<delim>
154
+ | liquidExpression<delim>
155
+ liquidJsonSep = space* "," space*
133
156
 
134
157
  liquidTagHashAssign = liquidTagRule<"hash_assign", liquidTagHashAssignMarkup>
135
158
  liquidTagHashAssignMarkup = liquidVariableLookup<delimTag> space* "=" space* liquidVariable<delimTag>
@@ -142,12 +165,6 @@ Liquid <: Helpers {
142
165
  liquidTagOpenCapture = liquidTagOpenRule<"capture", variableSegmentAsLookupMarkup>
143
166
  variableSegmentAsLookupMarkup = variableSegmentAsLookup space*
144
167
 
145
- liquidTagSection = liquidTagRule<"section", liquidTagSectionMarkup>
146
- liquidTagSectionMarkup = liquidString<delimTag> space*
147
-
148
- liquidTagSections = liquidTagRule<"sections", liquidTagSectionsMarkup>
149
- liquidTagSectionsMarkup = liquidString<delimTag> space*
150
-
151
168
  liquidTagLayout = liquidTagRule<"layout", liquidTagLayoutMarkup>
152
169
  liquidTagLayoutMarkup = liquidExpression<delimTag> space*
153
170
 
@@ -162,15 +179,8 @@ Liquid <: Helpers {
162
179
  liquidTagLiquid = liquidTagRule<"liquid", liquidTagLiquidMarkup>
163
180
  liquidTagLiquidMarkup = tagMarkup
164
181
 
165
- liquidTagContentFor = liquidTagRule<"content_for", liquidTagContentForMarkup>
166
-
167
- liquidTagContentForMarkup =
168
- contentForType (argumentSeparatorOptionalComma contentForTagArgument) (space* ",")? space*
169
-
170
- contentForTagArgument = listOf<contentForNamedArgument<delimTag>, argumentSeparatorOptionalComma>
171
- completionModeContentForTagArgument = listOf<contentForNamedArgument<delimTag>, argumentSeparatorOptionalComma> (argumentSeparator? (liquidVariableLookup<delimTag>))?
172
- contentForNamedArgument<delim> = (variableSegment ("." variableSegment)*) space* ":" space* (liquidExpression<delim>)
173
-
182
+ liquidTagOpenContentFor = liquidTagOpenRule<"content_for", liquidTagContentForMarkup>
183
+ liquidTagContentForMarkup = contentForType space*
174
184
  contentForType = liquidString<delimTag>
175
185
 
176
186
  liquidTagInclude = liquidTagRule<"include", liquidTagRenderMarkup>
@@ -259,7 +269,6 @@ Liquid <: Helpers {
259
269
  liquidTagOpenBaseCase = liquidTagOpenRule<blockNameNotSpecial, tagMarkup>
260
270
  blockNameNotSpecial =
261
271
  ( "form"
262
- | "paginate"
263
272
  | "capture"
264
273
  | "case"
265
274
  | "for"
@@ -278,6 +287,7 @@ Liquid <: Helpers {
278
287
  liquidTagOpenFormMarkup = arguments<delimTag> (space* ",")? space*
279
288
 
280
289
  liquidTagOpenFor = liquidTagOpenRule<"for", liquidTagOpenForMarkup>
290
+
281
291
  liquidTagOpenForMarkup =
282
292
  variableSegment space* "in" space* liquidExpression<delimTag>
283
293
  (space* "reversed")? argumentSeparatorOptionalComma
@@ -315,10 +325,6 @@ Liquid <: Helpers {
315
325
  | "<")
316
326
  | ("contains" ~identifier)
317
327
 
318
- liquidTagOpenPaginate = liquidTagOpenRule<"paginate", liquidTagOpenPaginateMarkup>
319
- liquidTagOpenPaginateMarkup =
320
- liquidExpression<delimTag> space+ "by" space+ liquidExpression<delimTag> argumentSeparatorOptionalComma tagArguments (space* ",")? space*
321
-
322
328
  liquidDrop = "{{" "-"? space* liquidDropCases "-"? "}}"
323
329
  liquidDropCases = liquidVariable<delimVO> | liquidDropBaseCase
324
330
  liquidDropBaseCase = anyExceptStar<delimVO>
@@ -326,10 +332,6 @@ Liquid <: Helpers {
326
332
 
327
333
  liquidRawTag =
328
334
  | liquidRawTagImpl<"raw">
329
- | liquidRawTagImpl<"javascript">
330
- | liquidRawTagImpl<"schema">
331
- | liquidRawTagImpl<"stylesheet">
332
- | liquidRawTagImpl<"style">
333
335
  liquidRawTagImpl<name> =
334
336
  "{%" "-"? space* (name endOfIdentifier) space* tagMarkup "-"? "%}"
335
337
  anyExceptStar<liquidRawTagClose<name>>
@@ -434,9 +436,7 @@ Liquid <: Helpers {
434
436
  letter (alnum | "_")*
435
437
 
436
438
  blockName =
437
- // Shopify blocks
438
439
  ( "form"
439
- | "paginate"
440
440
  // Base blocks
441
441
  | "capture"
442
442
  | "case"
@@ -449,6 +449,7 @@ Liquid <: Helpers {
449
449
  // platformos blocks
450
450
  | "background"
451
451
  | "cache"
452
+ | "content_for"
452
453
  | "parse_json"
453
454
  | "transaction"
454
455
  | "try"
@@ -707,8 +708,6 @@ StrictLiquidHTML <: LiquidHTML {
707
708
 
708
709
  WithPlaceholderLiquid <: Liquid {
709
710
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
710
- liquidTagContentForMarkup :=
711
- contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
712
711
  liquidTagRenderMarkup :=
713
712
  snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
714
713
  liquidTagName := (letter | "█") (alnum | "_")*
@@ -721,8 +720,6 @@ WithPlaceholderLiquid <: Liquid {
721
720
 
722
721
  WithPlaceholderLiquidStatement <: LiquidStatement {
723
722
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
724
- liquidTagContentForMarkup :=
725
- contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
726
723
  liquidTagRenderMarkup :=
727
724
  snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
728
725
  liquidTagName := (letter | "█") (alnum | "_")*
@@ -735,8 +732,6 @@ WithPlaceholderLiquidStatement <: LiquidStatement {
735
732
 
736
733
  WithPlaceholderLiquidHTML <: LiquidHTML {
737
734
  liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
738
- liquidTagContentForMarkup :=
739
- contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
740
735
  liquidTagRenderMarkup :=
741
736
  snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
742
737
  liquidTagName := (letter | "█") (alnum | "_")*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/liquid-html-parser",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Liquid HTML parser for platformOS",
5
5
  "author": "platformOS",
6
6
  "homepage": "https://github.com/Platform-OS/platformos-tools/tree/master/packages/liquid-html-parser#readme",