@platformos/liquid-html-parser 0.0.7 → 0.0.9
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 +7 -14
- package/dist/stage-1-cst.d.ts +27 -19
- package/dist/stage-1-cst.js +122 -42
- package/dist/stage-2-ast.d.ts +42 -38
- package/dist/stage-2-ast.js +53 -53
- package/dist/types.d.ts +4 -4
- package/dist/types.js +4 -4
- package/grammar/liquid-html.ohm +64 -48
- package/grammar/liquid-html.ohm.js +57 -40
- package/package.json +1 -1
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 =
|
|
27
|
-
|
|
28
|
-
.
|
|
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
|
package/dist/stage-1-cst.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare enum ConcreteNodeTypes {
|
|
|
62
62
|
Comparison = "Comparison",
|
|
63
63
|
Condition = "Condition",
|
|
64
64
|
AssignMarkup = "AssignMarkup",
|
|
65
|
+
AssignPushRhs = "AssignPushRhs",
|
|
65
66
|
HashAssignMarkup = "HashAssignMarkup",
|
|
66
67
|
ContentForMarkup = "ContentForMarkup",
|
|
67
68
|
CycleMarkup = "CycleMarkup",
|
|
@@ -70,7 +71,6 @@ export declare enum ConcreteNodeTypes {
|
|
|
70
71
|
FunctionMarkup = "FunctionMarkup",
|
|
71
72
|
GraphQLMarkup = "GraphQLMarkup",
|
|
72
73
|
GraphQLInlineMarkup = "GraphQLInlineMarkup",
|
|
73
|
-
PaginateMarkup = "PaginateMarkup",
|
|
74
74
|
RenderVariableExpression = "RenderVariableExpression",
|
|
75
75
|
RenderAliasExpression = "RenderAliasExpression",
|
|
76
76
|
ContentForNamedArgument = "ContentForNamedArgument",
|
|
@@ -79,6 +79,9 @@ export declare enum ConcreteNodeTypes {
|
|
|
79
79
|
LiquidDocDescriptionNode = "LiquidDocDescriptionNode",
|
|
80
80
|
LiquidDocExampleNode = "LiquidDocExampleNode",
|
|
81
81
|
LiquidDocPromptNode = "LiquidDocPromptNode",
|
|
82
|
+
JsonHashLiteral = "JsonHashLiteral",
|
|
83
|
+
JsonArrayLiteral = "JsonArrayLiteral",
|
|
84
|
+
JsonKeyValuePair = "JsonKeyValuePair",
|
|
82
85
|
BackgroundMarkup = "BackgroundMarkup",
|
|
83
86
|
BackgroundInlineMarkup = "BackgroundInlineMarkup",
|
|
84
87
|
CacheMarkup = "CacheMarkup",
|
|
@@ -194,7 +197,7 @@ export interface ConcreteLiquidRawTag extends ConcreteBasicLiquidNode<ConcreteNo
|
|
|
194
197
|
blockEndLocEnd: number;
|
|
195
198
|
}
|
|
196
199
|
export type ConcreteLiquidTagOpen = ConcreteLiquidTagOpenBaseCase | ConcreteLiquidTagOpenNamed;
|
|
197
|
-
export type ConcreteLiquidTagOpenNamed = ConcreteLiquidTagOpenCase | ConcreteLiquidTagOpenCapture | ConcreteLiquidTagOpenGraphQL | ConcreteLiquidTagOpenIf | ConcreteLiquidTagOpenUnless | ConcreteLiquidTagOpenForm | ConcreteLiquidTagOpenFor |
|
|
200
|
+
export type ConcreteLiquidTagOpenNamed = ConcreteLiquidTagOpenCase | ConcreteLiquidTagOpenCapture | ConcreteLiquidTagOpenGraphQL | ConcreteLiquidTagOpenIf | ConcreteLiquidTagOpenUnless | ConcreteLiquidTagOpenForm | ConcreteLiquidTagOpenFor | ConcreteLiquidTagOpenTablerow | ConcreteLiquidTagOpenBackground | ConcreteLiquidTagOpenCache | ConcreteLiquidTagOpenContentFor | ConcreteLiquidTagOpenParseJson | ConcreteLiquidTagOpenTransaction | ConcreteLiquidTagOpenTry;
|
|
198
201
|
export interface ConcreteLiquidTagOpenNode<Name, Markup> extends ConcreteBasicLiquidNode<ConcreteNodeTypes.LiquidTagOpen> {
|
|
199
202
|
name: Name;
|
|
200
203
|
markup: Markup;
|
|
@@ -236,18 +239,11 @@ export interface ConcreteLiquidTagForMarkup extends ConcreteBasicNode<ConcreteNo
|
|
|
236
239
|
}
|
|
237
240
|
export interface ConcreteLiquidTagOpenTablerow extends ConcreteLiquidTagOpenNode<NamedTags.tablerow, ConcreteLiquidTagForMarkup> {
|
|
238
241
|
}
|
|
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
242
|
export interface ConcreteLiquidTagClose extends ConcreteBasicLiquidNode<ConcreteNodeTypes.LiquidTagClose> {
|
|
247
243
|
name: string;
|
|
248
244
|
}
|
|
249
245
|
export type ConcreteLiquidTag = ConcreteLiquidTagNamed | ConcreteLiquidTagBaseCase;
|
|
250
|
-
export type ConcreteLiquidTagNamed = ConcreteLiquidTagAssign | ConcreteLiquidTagHashAssign | ConcreteLiquidTagCycle |
|
|
246
|
+
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
247
|
export interface ConcreteLiquidTagNode<Name, Markup> extends ConcreteBasicLiquidNode<ConcreteNodeTypes.LiquidTag> {
|
|
252
248
|
markup: Markup;
|
|
253
249
|
name: Name;
|
|
@@ -260,10 +256,6 @@ export interface ConcreteLiquidTagIncrement extends ConcreteLiquidTagNode<NamedT
|
|
|
260
256
|
}
|
|
261
257
|
export interface ConcreteLiquidTagDecrement extends ConcreteLiquidTagNode<NamedTags.decrement, ConcreteLiquidVariableLookup> {
|
|
262
258
|
}
|
|
263
|
-
export interface ConcreteLiquidTagSection extends ConcreteLiquidTagNode<NamedTags.section, ConcreteStringLiteral> {
|
|
264
|
-
}
|
|
265
|
-
export interface ConcreteLiquidTagSections extends ConcreteLiquidTagNode<NamedTags.sections, ConcreteStringLiteral> {
|
|
266
|
-
}
|
|
267
259
|
export interface ConcreteLiquidTagLayout extends ConcreteLiquidTagNode<NamedTags.layout, ConcreteLiquidExpression> {
|
|
268
260
|
}
|
|
269
261
|
export interface ConcreteLiquidTagLiquid extends ConcreteLiquidTagNode<NamedTags.liquid, ConcreteLiquidLiquidTagNode[]> {
|
|
@@ -271,9 +263,15 @@ export interface ConcreteLiquidTagLiquid extends ConcreteLiquidTagNode<NamedTags
|
|
|
271
263
|
export type ConcreteLiquidLiquidTagNode = ConcreteLiquidTagOpen | ConcreteLiquidTagClose | ConcreteLiquidTag | ConcreteLiquidRawTag;
|
|
272
264
|
export interface ConcreteLiquidTagAssign extends ConcreteLiquidTagNode<NamedTags.assign, ConcreteLiquidTagAssignMarkup> {
|
|
273
265
|
}
|
|
266
|
+
export interface ConcreteLiquidTagAssignPushRhs extends ConcreteBasicNode<ConcreteNodeTypes.AssignPushRhs> {
|
|
267
|
+
pushSource: ConcreteLiquidVariable;
|
|
268
|
+
pushValue: ConcreteLiquidVariable;
|
|
269
|
+
}
|
|
274
270
|
export interface ConcreteLiquidTagAssignMarkup extends ConcreteBasicNode<ConcreteNodeTypes.AssignMarkup> {
|
|
275
271
|
name: string;
|
|
276
|
-
|
|
272
|
+
target: ConcreteLiquidVariableLookup;
|
|
273
|
+
operator: string;
|
|
274
|
+
value: ConcreteLiquidVariable | ConcreteLiquidTagAssignPushRhs;
|
|
277
275
|
}
|
|
278
276
|
export interface ConcreteLiquidTagHashAssign extends ConcreteLiquidTagNode<NamedTags.hash_assign, ConcreteLiquidTagHashAssignMarkup> {
|
|
279
277
|
}
|
|
@@ -287,7 +285,7 @@ export interface ConcreteLiquidTagCycleMarkup extends ConcreteBasicNode<Concrete
|
|
|
287
285
|
groupName: ConcreteLiquidExpression | null;
|
|
288
286
|
args: ConcreteLiquidExpression[];
|
|
289
287
|
}
|
|
290
|
-
export interface
|
|
288
|
+
export interface ConcreteLiquidTagOpenContentFor extends ConcreteLiquidTagOpenNode<NamedTags.content_for, ConcreteLiquidTagContentForMarkup> {
|
|
291
289
|
}
|
|
292
290
|
export interface ConcreteLiquidTagRender extends ConcreteLiquidTagNode<NamedTags.render, ConcreteLiquidTagRenderMarkup> {
|
|
293
291
|
}
|
|
@@ -343,7 +341,6 @@ export interface ConcreteLiquidTagOpenTry extends ConcreteLiquidTagOpenNode<Name
|
|
|
343
341
|
}
|
|
344
342
|
export interface ConcreteLiquidTagContentForMarkup extends ConcreteBasicNode<ConcreteNodeTypes.ContentForMarkup> {
|
|
345
343
|
contentForType: ConcreteStringLiteral;
|
|
346
|
-
args: ConcreteLiquidNamedArgument[];
|
|
347
344
|
}
|
|
348
345
|
export interface ConcreteLiquidTagRenderMarkup extends ConcreteBasicNode<ConcreteNodeTypes.RenderMarkup> {
|
|
349
346
|
snippet: ConcreteStringLiteral | ConcreteLiquidVariableLookup;
|
|
@@ -424,9 +421,9 @@ export interface ConcreteLiquidFilter extends ConcreteBasicNode<ConcreteNodeType
|
|
|
424
421
|
export type ConcreteLiquidArgument = ConcreteLiquidExpression | ConcreteLiquidNamedArgument;
|
|
425
422
|
export interface ConcreteLiquidNamedArgument extends ConcreteBasicNode<ConcreteNodeTypes.NamedArgument> {
|
|
426
423
|
name: string;
|
|
427
|
-
value: ConcreteLiquidExpression;
|
|
424
|
+
value: ConcreteLiquidExpression | ConcreteLiquidVariable;
|
|
428
425
|
}
|
|
429
|
-
export type ConcreteLiquidExpression = ConcreteStringLiteral | ConcreteNumberLiteral | ConcreteLiquidLiteral | ConcreteLiquidRange | ConcreteLiquidVariableLookup;
|
|
426
|
+
export type ConcreteLiquidExpression = ConcreteStringLiteral | ConcreteNumberLiteral | ConcreteLiquidLiteral | ConcreteLiquidRange | ConcreteLiquidVariableLookup | ConcreteJsonHashLiteral | ConcreteJsonArrayLiteral;
|
|
430
427
|
export type ConcreteComplexLiquidExpression = ConcreteLiquidBooleanExpression | ConcreteLiquidExpression;
|
|
431
428
|
export interface ConcreteLiquidBooleanExpression extends ConcreteBasicNode<ConcreteNodeTypes.BooleanExpression> {
|
|
432
429
|
conditions: ConcreteLiquidCondition[];
|
|
@@ -450,6 +447,17 @@ export interface ConcreteLiquidVariableLookup extends ConcreteBasicNode<Concrete
|
|
|
450
447
|
name: string | null;
|
|
451
448
|
lookups: ConcreteLiquidExpression[];
|
|
452
449
|
}
|
|
450
|
+
export interface ConcreteJsonHashLiteral extends ConcreteBasicNode<ConcreteNodeTypes.JsonHashLiteral> {
|
|
451
|
+
entries: ConcreteJsonKeyValuePair[];
|
|
452
|
+
}
|
|
453
|
+
export interface ConcreteJsonKeyValuePair extends ConcreteBasicNode<ConcreteNodeTypes.JsonKeyValuePair> {
|
|
454
|
+
key: ConcreteLiquidExpression;
|
|
455
|
+
value: ConcreteJsonValue;
|
|
456
|
+
}
|
|
457
|
+
export interface ConcreteJsonArrayLiteral extends ConcreteBasicNode<ConcreteNodeTypes.JsonArrayLiteral> {
|
|
458
|
+
elements: ConcreteJsonValue[];
|
|
459
|
+
}
|
|
460
|
+
export type ConcreteJsonValue = ConcreteJsonHashLiteral | ConcreteJsonArrayLiteral | ConcreteLiquidVariable | ConcreteLiquidExpression;
|
|
453
461
|
export type ConcreteHtmlNode = ConcreteHtmlDoctype | ConcreteHtmlComment | ConcreteHtmlRawTag | ConcreteHtmlVoidElement | ConcreteHtmlSelfClosingElement | ConcreteHtmlTagOpen | ConcreteHtmlTagClose;
|
|
454
462
|
export interface ConcreteTextNode extends ConcreteBasicNode<ConcreteNodeTypes.TextNode> {
|
|
455
463
|
value: string;
|
package/dist/stage-1-cst.js
CHANGED
|
@@ -70,6 +70,7 @@ var ConcreteNodeTypes;
|
|
|
70
70
|
ConcreteNodeTypes["Comparison"] = "Comparison";
|
|
71
71
|
ConcreteNodeTypes["Condition"] = "Condition";
|
|
72
72
|
ConcreteNodeTypes["AssignMarkup"] = "AssignMarkup";
|
|
73
|
+
ConcreteNodeTypes["AssignPushRhs"] = "AssignPushRhs";
|
|
73
74
|
ConcreteNodeTypes["HashAssignMarkup"] = "HashAssignMarkup";
|
|
74
75
|
ConcreteNodeTypes["ContentForMarkup"] = "ContentForMarkup";
|
|
75
76
|
ConcreteNodeTypes["CycleMarkup"] = "CycleMarkup";
|
|
@@ -78,7 +79,6 @@ var ConcreteNodeTypes;
|
|
|
78
79
|
ConcreteNodeTypes["FunctionMarkup"] = "FunctionMarkup";
|
|
79
80
|
ConcreteNodeTypes["GraphQLMarkup"] = "GraphQLMarkup";
|
|
80
81
|
ConcreteNodeTypes["GraphQLInlineMarkup"] = "GraphQLInlineMarkup";
|
|
81
|
-
ConcreteNodeTypes["PaginateMarkup"] = "PaginateMarkup";
|
|
82
82
|
ConcreteNodeTypes["RenderVariableExpression"] = "RenderVariableExpression";
|
|
83
83
|
ConcreteNodeTypes["RenderAliasExpression"] = "RenderAliasExpression";
|
|
84
84
|
ConcreteNodeTypes["ContentForNamedArgument"] = "ContentForNamedArgument";
|
|
@@ -87,6 +87,9 @@ var ConcreteNodeTypes;
|
|
|
87
87
|
ConcreteNodeTypes["LiquidDocDescriptionNode"] = "LiquidDocDescriptionNode";
|
|
88
88
|
ConcreteNodeTypes["LiquidDocExampleNode"] = "LiquidDocExampleNode";
|
|
89
89
|
ConcreteNodeTypes["LiquidDocPromptNode"] = "LiquidDocPromptNode";
|
|
90
|
+
ConcreteNodeTypes["JsonHashLiteral"] = "JsonHashLiteral";
|
|
91
|
+
ConcreteNodeTypes["JsonArrayLiteral"] = "JsonArrayLiteral";
|
|
92
|
+
ConcreteNodeTypes["JsonKeyValuePair"] = "JsonKeyValuePair";
|
|
90
93
|
// platformos markup types
|
|
91
94
|
ConcreteNodeTypes["BackgroundMarkup"] = "BackgroundMarkup";
|
|
92
95
|
ConcreteNodeTypes["BackgroundInlineMarkup"] = "BackgroundInlineMarkup";
|
|
@@ -167,23 +170,9 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
167
170
|
name: 3,
|
|
168
171
|
body: 9,
|
|
169
172
|
children: (tokens) => {
|
|
170
|
-
|
|
173
|
+
// {% raw %} accepts syntax errors, we shouldn't try to parse that
|
|
171
174
|
const rawMarkupStringNode = tokens[9];
|
|
172
|
-
|
|
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
|
-
}
|
|
175
|
+
return toCST(source, grammars, grammar_1.TextNodeGrammar, ['HelperMappings'], rawMarkupStringNode.sourceString, offset + rawMarkupStringNode.source.startIdx);
|
|
187
176
|
},
|
|
188
177
|
markup: 6,
|
|
189
178
|
whitespaceStart: 1,
|
|
@@ -285,16 +274,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
285
274
|
liquidTagBreak: 0,
|
|
286
275
|
liquidTagContinue: 0,
|
|
287
276
|
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
277
|
liquidTagOpenCase: 0,
|
|
299
278
|
liquidTagOpenCaseMarkup: 0,
|
|
300
279
|
liquidTagWhen: 0,
|
|
@@ -344,8 +323,6 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
344
323
|
liquidTagFunction: 0,
|
|
345
324
|
liquidTagGraphQL: 0,
|
|
346
325
|
liquidTagInclude: 0,
|
|
347
|
-
liquidTagSection: 0,
|
|
348
|
-
liquidTagSections: 0,
|
|
349
326
|
liquidTagLayout: 0,
|
|
350
327
|
liquidTagRule: {
|
|
351
328
|
type: ConcreteNodeTypes.LiquidTag,
|
|
@@ -369,17 +346,99 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
369
346
|
return toCST(source, grammars, grammars.LiquidStatement, ['HelperMappings', 'LiquidMappings', 'LiquidStatement'], tagMarkup.sourceString, offset + tagMarkup.source.startIdx);
|
|
370
347
|
},
|
|
371
348
|
liquidTagEchoMarkup: 0,
|
|
372
|
-
liquidTagSectionMarkup: 0,
|
|
373
|
-
liquidTagSectionsMarkup: 0,
|
|
374
349
|
liquidTagLayoutMarkup: 0,
|
|
375
350
|
liquidTagAssignMarkup: {
|
|
376
351
|
type: ConcreteNodeTypes.AssignMarkup,
|
|
352
|
+
name: (tokens) => tokens[0].children[0].sourceString,
|
|
353
|
+
target: 0,
|
|
354
|
+
operator: 2,
|
|
355
|
+
value: 4,
|
|
356
|
+
locStart,
|
|
357
|
+
locEnd,
|
|
358
|
+
source,
|
|
359
|
+
},
|
|
360
|
+
assignTarget: {
|
|
361
|
+
type: ConcreteNodeTypes.VariableLookup,
|
|
377
362
|
name: 0,
|
|
363
|
+
lookups: 1,
|
|
364
|
+
locStart,
|
|
365
|
+
locEnd,
|
|
366
|
+
source,
|
|
367
|
+
},
|
|
368
|
+
assignOperator: (node) => node.sourceString,
|
|
369
|
+
liquidAssignValue: 0,
|
|
370
|
+
liquidAssignPushExpr: {
|
|
371
|
+
type: ConcreteNodeTypes.AssignPushRhs,
|
|
372
|
+
// tokens: [pushSource, space*, "<<", space*, pushValue]
|
|
373
|
+
pushSource: 0,
|
|
374
|
+
pushValue: 4,
|
|
375
|
+
locStart,
|
|
376
|
+
locEnd,
|
|
377
|
+
source,
|
|
378
|
+
},
|
|
379
|
+
liquidAssignPushSource: {
|
|
380
|
+
type: ConcreteNodeTypes.LiquidVariable,
|
|
381
|
+
expression: 0,
|
|
382
|
+
filters: 1,
|
|
383
|
+
// No &delim lookahead at end (unlike liquidAssignVariable), so last token is space*
|
|
384
|
+
rawSource: (tokens) => source.slice(locStart(tokens), tokens[tokens.length - 1].source.endIdx).trimEnd(),
|
|
385
|
+
locStart,
|
|
386
|
+
locEnd,
|
|
387
|
+
source,
|
|
388
|
+
},
|
|
389
|
+
liquidAssignVariable: {
|
|
390
|
+
type: ConcreteNodeTypes.LiquidVariable,
|
|
391
|
+
expression: 0,
|
|
392
|
+
filters: 1,
|
|
393
|
+
rawSource: (tokens) => source.slice(locStart(tokens), tokens[tokens.length - 2].source.endIdx).trimEnd(),
|
|
394
|
+
locStart,
|
|
395
|
+
locEnd: locEndSecondToLast,
|
|
396
|
+
source,
|
|
397
|
+
},
|
|
398
|
+
liquidAssignExpression: 0,
|
|
399
|
+
liquidJsonHashLiteral: {
|
|
400
|
+
type: ConcreteNodeTypes.JsonHashLiteral,
|
|
401
|
+
entries: 2,
|
|
402
|
+
locStart,
|
|
403
|
+
locEnd,
|
|
404
|
+
source,
|
|
405
|
+
},
|
|
406
|
+
liquidJsonKeyValue: {
|
|
407
|
+
type: ConcreteNodeTypes.JsonKeyValuePair,
|
|
408
|
+
key: 0,
|
|
378
409
|
value: 4,
|
|
379
410
|
locStart,
|
|
380
411
|
locEnd,
|
|
381
412
|
source,
|
|
382
413
|
},
|
|
414
|
+
liquidJsonKey: 0,
|
|
415
|
+
liquidJsonBareKey: {
|
|
416
|
+
type: ConcreteNodeTypes.VariableLookup,
|
|
417
|
+
name: 0,
|
|
418
|
+
lookups: () => [],
|
|
419
|
+
locStart,
|
|
420
|
+
locEnd,
|
|
421
|
+
source,
|
|
422
|
+
},
|
|
423
|
+
liquidJsonArrayLiteral: {
|
|
424
|
+
type: ConcreteNodeTypes.JsonArrayLiteral,
|
|
425
|
+
elements: 2,
|
|
426
|
+
locStart,
|
|
427
|
+
locEnd,
|
|
428
|
+
source,
|
|
429
|
+
},
|
|
430
|
+
liquidJsonValue: 0,
|
|
431
|
+
liquidJsonItemVariable: {
|
|
432
|
+
type: ConcreteNodeTypes.LiquidVariable,
|
|
433
|
+
expression: 0,
|
|
434
|
+
filters: 1,
|
|
435
|
+
// No &delim lookahead at end (unlike liquidVariable), so last token is space*
|
|
436
|
+
rawSource: (tokens) => source.slice(locStart(tokens), tokens[tokens.length - 1].source.endIdx).trimEnd(),
|
|
437
|
+
locStart,
|
|
438
|
+
locEnd,
|
|
439
|
+
source,
|
|
440
|
+
},
|
|
441
|
+
liquidJsonSep: 1,
|
|
383
442
|
liquidTagHashAssignMarkup: {
|
|
384
443
|
type: ConcreteNodeTypes.HashAssignMarkup,
|
|
385
444
|
target: 0,
|
|
@@ -396,10 +455,10 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
396
455
|
locEnd,
|
|
397
456
|
source,
|
|
398
457
|
},
|
|
458
|
+
liquidTagOpenContentFor: 0,
|
|
399
459
|
liquidTagContentForMarkup: {
|
|
400
460
|
type: ConcreteNodeTypes.ContentForMarkup,
|
|
401
461
|
contentForType: 0,
|
|
402
|
-
args: 2,
|
|
403
462
|
locStart,
|
|
404
463
|
locEnd,
|
|
405
464
|
source,
|
|
@@ -609,6 +668,23 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
609
668
|
}
|
|
610
669
|
},
|
|
611
670
|
},
|
|
671
|
+
// Same as liquidFilter but without trailing comma — used inside JSON values to avoid
|
|
672
|
+
// consuming JSON entry separator commas as trailing filter argument commas.
|
|
673
|
+
liquidJsonFilter: {
|
|
674
|
+
type: ConcreteNodeTypes.LiquidFilter,
|
|
675
|
+
name: 3,
|
|
676
|
+
locStart,
|
|
677
|
+
locEnd,
|
|
678
|
+
source,
|
|
679
|
+
args(nodes) {
|
|
680
|
+
if (nodes[7].sourceString === '') {
|
|
681
|
+
return [];
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
return nodes[7].toAST(this.args.mapping);
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
},
|
|
612
688
|
filterArguments: 0,
|
|
613
689
|
arguments: 0,
|
|
614
690
|
complexArguments: function (completeParams, _space1, _comma, _space2, incompleteParam) {
|
|
@@ -619,13 +695,8 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
619
695
|
},
|
|
620
696
|
simpleArgument: 0,
|
|
621
697
|
tagArguments: 0,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const self = this;
|
|
625
|
-
return namedArguments
|
|
626
|
-
.toAST(self.args.mapping)
|
|
627
|
-
.concat(variableLookup.sourceString === '' ? [] : variableLookup.toAST(self.args.mapping));
|
|
628
|
-
},
|
|
698
|
+
graphqlArguments: 0,
|
|
699
|
+
graphqlRenderArguments: 1,
|
|
629
700
|
positionalArgument: 0,
|
|
630
701
|
namedArgument: {
|
|
631
702
|
type: ConcreteNodeTypes.NamedArgument,
|
|
@@ -635,10 +706,19 @@ function toCST(source /* the original file */, grammars, grammar, cstMappings, m
|
|
|
635
706
|
locEnd,
|
|
636
707
|
source,
|
|
637
708
|
},
|
|
638
|
-
|
|
709
|
+
graphqlNamedArgument: {
|
|
639
710
|
type: ConcreteNodeTypes.NamedArgument,
|
|
640
|
-
name:
|
|
641
|
-
value:
|
|
711
|
+
name: 0,
|
|
712
|
+
value: 4,
|
|
713
|
+
locStart,
|
|
714
|
+
locEnd,
|
|
715
|
+
source,
|
|
716
|
+
},
|
|
717
|
+
graphqlNamedArgumentValue: {
|
|
718
|
+
type: ConcreteNodeTypes.LiquidVariable,
|
|
719
|
+
expression: 0,
|
|
720
|
+
filters: 1,
|
|
721
|
+
rawSource: (tokens) => source.slice(locStart(tokens), locEnd(tokens)),
|
|
642
722
|
locStart,
|
|
643
723
|
locEnd,
|
|
644
724
|
source,
|
package/dist/stage-2-ast.d.ts
CHANGED
|
@@ -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 |
|
|
38
|
+
export type LiquidHtmlNode = DocumentNode | YAMLFrontmatter | LiquidNode | HtmlDoctype | HtmlNode | AttributeNode | LiquidVariable | ComplexLiquidExpression | LiquidFilter | LiquidNamedArgument | AssignMarkup | AssignPushRhs | 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 |
|
|
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,10 +137,21 @@ 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
|
|
140
|
+
/** the base variable name (backward compatible) */
|
|
141
141
|
name: string;
|
|
142
|
-
/**
|
|
143
|
-
|
|
142
|
+
/** bracket/dot lookups on the target (empty for simple assignment) */
|
|
143
|
+
lookups: LiquidExpression[];
|
|
144
|
+
/** '=' for assignment, '<<' for array append */
|
|
145
|
+
operator: '=' | '<<';
|
|
146
|
+
/** the value of the variable that is being assigned, or a push expression */
|
|
147
|
+
value: LiquidVariable | AssignPushRhs;
|
|
148
|
+
}
|
|
149
|
+
/** The RHS of an explicit push assign: `assign a = source << value` */
|
|
150
|
+
export interface AssignPushRhs extends ASTNode<NodeTypes.AssignPushRhs> {
|
|
151
|
+
/** the source array to push into */
|
|
152
|
+
pushSource: LiquidVariable;
|
|
153
|
+
/** the value being pushed */
|
|
154
|
+
pushValue: LiquidVariable;
|
|
144
155
|
}
|
|
145
156
|
export interface LiquidTagHashAssign extends LiquidTagNode<NamedTags.hash_assign, HashAssignMarkup> {
|
|
146
157
|
}
|
|
@@ -224,19 +235,11 @@ export interface LiquidComparison extends ASTNode<NodeTypes.Comparison> {
|
|
|
224
235
|
left: LiquidExpression;
|
|
225
236
|
right: LiquidExpression;
|
|
226
237
|
}
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
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 */
|
|
238
|
+
/**
|
|
239
|
+
* In platformOS, content_for defines a named block of content in a page/partial.
|
|
240
|
+
* Use {% yield 'name' %} in a layout to render it.
|
|
241
|
+
* @example {% content_for 'pagetitle' %}<title>Hello</title>{% endcontent_for %}
|
|
242
|
+
*/
|
|
240
243
|
export interface LiquidTagContentFor extends LiquidTagNode<NamedTags.content_for, ContentForMarkup> {
|
|
241
244
|
}
|
|
242
245
|
/** https://shopify.dev/docs/api/liquid/tags#render */
|
|
@@ -249,30 +252,15 @@ export interface LiquidTagGraphQL extends LiquidTagNode<NamedTags.graphql, Graph
|
|
|
249
252
|
/** https://shopify.dev/docs/api/liquid/tags#include */
|
|
250
253
|
export interface LiquidTagInclude extends LiquidTagNode<NamedTags.include, RenderMarkup> {
|
|
251
254
|
}
|
|
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
255
|
/** https://shopify.dev/docs/api/liquid/tags#layout */
|
|
259
256
|
export interface LiquidTagLayout extends LiquidTagNode<NamedTags.layout, LiquidExpression> {
|
|
260
257
|
}
|
|
261
258
|
/** https://shopify.dev/docs/api/liquid/tags#liquid */
|
|
262
259
|
export interface LiquidTagLiquid extends LiquidTagNode<NamedTags.liquid, LiquidStatement[]> {
|
|
263
260
|
}
|
|
264
|
-
/** {% content_for '
|
|
261
|
+
/** {% content_for 'name' %}...{% endcontent_for %} */
|
|
265
262
|
export interface ContentForMarkup extends ASTNode<NodeTypes.ContentForMarkup> {
|
|
266
|
-
/** {% content_for 'contentForType' %} */
|
|
267
263
|
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
264
|
}
|
|
277
265
|
/** {% render 'partial' [(with|for) variable [as alias]], [...namedArguments] %} */
|
|
278
266
|
export interface RenderMarkup extends ASTNode<NodeTypes.RenderMarkup> {
|
|
@@ -506,7 +494,7 @@ export interface LiquidVariable extends ASTNode<NodeTypes.LiquidVariable> {
|
|
|
506
494
|
rawSource: string;
|
|
507
495
|
}
|
|
508
496
|
/** The union type of all Liquid expression nodes */
|
|
509
|
-
export type LiquidExpression = LiquidString | LiquidNumber | LiquidLiteral | LiquidRange | LiquidVariableLookup;
|
|
497
|
+
export type LiquidExpression = LiquidString | LiquidNumber | LiquidLiteral | LiquidRange | LiquidVariableLookup | JsonHashLiteral | JsonArrayLiteral;
|
|
510
498
|
export type ComplexLiquidExpression = LiquidBooleanExpression | LiquidExpression;
|
|
511
499
|
/** https://shopify.dev/docs/api/liquid/filters */
|
|
512
500
|
export interface LiquidFilter extends ASTNode<NodeTypes.LiquidFilter> {
|
|
@@ -517,12 +505,15 @@ export interface LiquidFilter extends ASTNode<NodeTypes.LiquidFilter> {
|
|
|
517
505
|
}
|
|
518
506
|
/** Represents the union type of positional and named arguments */
|
|
519
507
|
export type LiquidArgument = LiquidExpression | LiquidNamedArgument;
|
|
520
|
-
/** Named arguments are the ones used in kwargs, such as `name: value` */
|
|
508
|
+
/** Named arguments are the ones used in kwargs, such as `name: value` or `name: value | filter` */
|
|
521
509
|
export interface LiquidNamedArgument extends ASTNode<NodeTypes.NamedArgument> {
|
|
522
510
|
/** name: value */
|
|
523
511
|
name: string;
|
|
524
|
-
/**
|
|
525
|
-
|
|
512
|
+
/**
|
|
513
|
+
* For regular tags (render, function, for, etc.): a plain LiquidExpression (no filters).
|
|
514
|
+
* For graphql tags: a LiquidVariable which may include filters (e.g. `name: val | fetch: "key"`).
|
|
515
|
+
*/
|
|
516
|
+
value: LiquidExpression | LiquidVariable;
|
|
526
517
|
}
|
|
527
518
|
export interface LiquidBooleanExpression extends ASTNode<NodeTypes.BooleanExpression> {
|
|
528
519
|
condition: LiquidConditionalExpression;
|
|
@@ -565,6 +556,19 @@ export interface LiquidVariableLookup extends ASTNode<NodeTypes.VariableLookup>
|
|
|
565
556
|
/** name.lookup1[lookup2] */
|
|
566
557
|
lookups: LiquidExpression[];
|
|
567
558
|
}
|
|
559
|
+
/** Represents a JSON hash literal { key: value, ... } */
|
|
560
|
+
export interface JsonHashLiteral extends ASTNode<NodeTypes.JsonHashLiteral> {
|
|
561
|
+
entries: JsonKeyValuePair[];
|
|
562
|
+
}
|
|
563
|
+
/** Represents a key-value pair in a JSON hash literal */
|
|
564
|
+
export interface JsonKeyValuePair extends ASTNode<NodeTypes.JsonKeyValuePair> {
|
|
565
|
+
key: LiquidExpression;
|
|
566
|
+
value: LiquidExpression | LiquidVariable;
|
|
567
|
+
}
|
|
568
|
+
/** Represents a JSON array literal [el1, el2, ...] */
|
|
569
|
+
export interface JsonArrayLiteral extends ASTNode<NodeTypes.JsonArrayLiteral> {
|
|
570
|
+
elements: (LiquidExpression | LiquidVariable)[];
|
|
571
|
+
}
|
|
568
572
|
/** The union type of all HTML nodes */
|
|
569
573
|
export type HtmlNode = HtmlComment | HtmlElement | HtmlDanglingMarkerClose | HtmlVoidElement | HtmlSelfClosingElement | HtmlRawNode;
|
|
570
574
|
/** The basic HTML node with an opening and closing tags. */
|
package/dist/stage-2-ast.js
CHANGED
|
@@ -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 {
|
|
@@ -913,10 +898,24 @@ function toUnnamedLiquidBranch(parentNode) {
|
|
|
913
898
|
};
|
|
914
899
|
}
|
|
915
900
|
function toAssignMarkup(node) {
|
|
901
|
+
const value = node.value.type === stage_1_cst_1.ConcreteNodeTypes.AssignPushRhs
|
|
902
|
+
? toAssignPushRhs(node.value)
|
|
903
|
+
: toLiquidVariable(node.value);
|
|
916
904
|
return {
|
|
917
905
|
type: types_1.NodeTypes.AssignMarkup,
|
|
918
906
|
name: node.name,
|
|
919
|
-
|
|
907
|
+
lookups: node.target.lookups.map(toExpression),
|
|
908
|
+
operator: node.operator,
|
|
909
|
+
value,
|
|
910
|
+
position: position(node),
|
|
911
|
+
source: node.source,
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
function toAssignPushRhs(node) {
|
|
915
|
+
return {
|
|
916
|
+
type: types_1.NodeTypes.AssignPushRhs,
|
|
917
|
+
pushSource: toLiquidVariable(node.pushSource),
|
|
918
|
+
pushValue: toLiquidVariable(node.pushValue),
|
|
920
919
|
position: position(node),
|
|
921
920
|
source: node.source,
|
|
922
921
|
};
|
|
@@ -950,16 +949,6 @@ function toForMarkup(node) {
|
|
|
950
949
|
source: node.source,
|
|
951
950
|
};
|
|
952
951
|
}
|
|
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
952
|
function toRawMarkup(node, options) {
|
|
964
953
|
return {
|
|
965
954
|
type: types_1.NodeTypes.RawMarkup,
|
|
@@ -1023,35 +1012,13 @@ function toRawMarkupKindFromHtmlNode(node) {
|
|
|
1023
1012
|
return RawMarkupKinds.text;
|
|
1024
1013
|
}
|
|
1025
1014
|
}
|
|
1026
|
-
function toRawMarkupKindFromLiquidNode(
|
|
1027
|
-
|
|
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
|
-
}
|
|
1015
|
+
function toRawMarkupKindFromLiquidNode(_node) {
|
|
1016
|
+
return RawMarkupKinds.text;
|
|
1041
1017
|
}
|
|
1042
1018
|
function toContentForMarkup(node) {
|
|
1043
1019
|
return {
|
|
1044
1020
|
type: types_1.NodeTypes.ContentForMarkup,
|
|
1045
1021
|
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
1022
|
position: position(node),
|
|
1056
1023
|
source: node.source,
|
|
1057
1024
|
};
|
|
@@ -1350,11 +1317,42 @@ function toExpression(node) {
|
|
|
1350
1317
|
source: node.source,
|
|
1351
1318
|
};
|
|
1352
1319
|
}
|
|
1320
|
+
case stage_1_cst_1.ConcreteNodeTypes.JsonHashLiteral: {
|
|
1321
|
+
return {
|
|
1322
|
+
type: types_1.NodeTypes.JsonHashLiteral,
|
|
1323
|
+
entries: node.entries.map(toJsonKeyValuePair),
|
|
1324
|
+
position: position(node),
|
|
1325
|
+
source: node.source,
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
case stage_1_cst_1.ConcreteNodeTypes.JsonArrayLiteral: {
|
|
1329
|
+
return {
|
|
1330
|
+
type: types_1.NodeTypes.JsonArrayLiteral,
|
|
1331
|
+
elements: node.elements.map(toJsonValue),
|
|
1332
|
+
position: position(node),
|
|
1333
|
+
source: node.source,
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1353
1336
|
default: {
|
|
1354
1337
|
return (0, utils_1.assertNever)(node);
|
|
1355
1338
|
}
|
|
1356
1339
|
}
|
|
1357
1340
|
}
|
|
1341
|
+
function toJsonValue(node) {
|
|
1342
|
+
if (node.type === stage_1_cst_1.ConcreteNodeTypes.LiquidVariable) {
|
|
1343
|
+
return toLiquidVariable(node);
|
|
1344
|
+
}
|
|
1345
|
+
return toExpression(node);
|
|
1346
|
+
}
|
|
1347
|
+
function toJsonKeyValuePair(node) {
|
|
1348
|
+
return {
|
|
1349
|
+
type: types_1.NodeTypes.JsonKeyValuePair,
|
|
1350
|
+
key: toExpression(node.key),
|
|
1351
|
+
value: toJsonValue(node.value),
|
|
1352
|
+
position: position(node),
|
|
1353
|
+
source: node.source,
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1358
1356
|
function toFilter(node) {
|
|
1359
1357
|
return {
|
|
1360
1358
|
type: types_1.NodeTypes.LiquidFilter,
|
|
@@ -1378,7 +1376,9 @@ function toNamedArgument(node) {
|
|
|
1378
1376
|
return {
|
|
1379
1377
|
type: types_1.NodeTypes.NamedArgument,
|
|
1380
1378
|
name: node.name,
|
|
1381
|
-
value:
|
|
1379
|
+
value: node.value.type === stage_1_cst_1.ConcreteNodeTypes.LiquidVariable
|
|
1380
|
+
? toLiquidVariable(node.value)
|
|
1381
|
+
: toExpression(node.value),
|
|
1382
1382
|
position: position(node),
|
|
1383
1383
|
source: node.source,
|
|
1384
1384
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -35,11 +35,11 @@ export declare enum NodeTypes {
|
|
|
35
35
|
Comparison = "Comparison",
|
|
36
36
|
LogicalExpression = "LogicalExpression",
|
|
37
37
|
AssignMarkup = "AssignMarkup",
|
|
38
|
+
AssignPushRhs = "AssignPushRhs",
|
|
38
39
|
HashAssignMarkup = "HashAssignMarkup",
|
|
39
40
|
ContentForMarkup = "ContentForMarkup",
|
|
40
41
|
CycleMarkup = "CycleMarkup",
|
|
41
42
|
ForMarkup = "ForMarkup",
|
|
42
|
-
PaginateMarkup = "PaginateMarkup",
|
|
43
43
|
RawMarkup = "RawMarkup",
|
|
44
44
|
RenderMarkup = "RenderMarkup",
|
|
45
45
|
FunctionMarkup = "FunctionMarkup",
|
|
@@ -51,6 +51,9 @@ export declare enum NodeTypes {
|
|
|
51
51
|
LiquidDocParamNode = "LiquidDocParamNode",
|
|
52
52
|
LiquidDocExampleNode = "LiquidDocExampleNode",
|
|
53
53
|
LiquidDocPromptNode = "LiquidDocPromptNode",
|
|
54
|
+
JsonHashLiteral = "JsonHashLiteral",
|
|
55
|
+
JsonArrayLiteral = "JsonArrayLiteral",
|
|
56
|
+
JsonKeyValuePair = "JsonKeyValuePair",
|
|
54
57
|
BackgroundMarkup = "BackgroundMarkup",
|
|
55
58
|
BackgroundInlineMarkup = "BackgroundInlineMarkup",
|
|
56
59
|
CacheMarkup = "CacheMarkup",
|
|
@@ -78,12 +81,9 @@ export declare enum NamedTags {
|
|
|
78
81
|
increment = "increment",
|
|
79
82
|
layout = "layout",
|
|
80
83
|
liquid = "liquid",
|
|
81
|
-
paginate = "paginate",
|
|
82
84
|
render = "render",
|
|
83
85
|
function = "function",
|
|
84
86
|
graphql = "graphql",
|
|
85
|
-
section = "section",
|
|
86
|
-
sections = "sections",
|
|
87
87
|
tablerow = "tablerow",
|
|
88
88
|
unless = "unless",
|
|
89
89
|
when = "when",
|
package/dist/types.js
CHANGED
|
@@ -33,11 +33,11 @@ var NodeTypes;
|
|
|
33
33
|
NodeTypes["Comparison"] = "Comparison";
|
|
34
34
|
NodeTypes["LogicalExpression"] = "LogicalExpression";
|
|
35
35
|
NodeTypes["AssignMarkup"] = "AssignMarkup";
|
|
36
|
+
NodeTypes["AssignPushRhs"] = "AssignPushRhs";
|
|
36
37
|
NodeTypes["HashAssignMarkup"] = "HashAssignMarkup";
|
|
37
38
|
NodeTypes["ContentForMarkup"] = "ContentForMarkup";
|
|
38
39
|
NodeTypes["CycleMarkup"] = "CycleMarkup";
|
|
39
40
|
NodeTypes["ForMarkup"] = "ForMarkup";
|
|
40
|
-
NodeTypes["PaginateMarkup"] = "PaginateMarkup";
|
|
41
41
|
NodeTypes["RawMarkup"] = "RawMarkup";
|
|
42
42
|
NodeTypes["RenderMarkup"] = "RenderMarkup";
|
|
43
43
|
NodeTypes["FunctionMarkup"] = "FunctionMarkup";
|
|
@@ -49,6 +49,9 @@ var NodeTypes;
|
|
|
49
49
|
NodeTypes["LiquidDocParamNode"] = "LiquidDocParamNode";
|
|
50
50
|
NodeTypes["LiquidDocExampleNode"] = "LiquidDocExampleNode";
|
|
51
51
|
NodeTypes["LiquidDocPromptNode"] = "LiquidDocPromptNode";
|
|
52
|
+
NodeTypes["JsonHashLiteral"] = "JsonHashLiteral";
|
|
53
|
+
NodeTypes["JsonArrayLiteral"] = "JsonArrayLiteral";
|
|
54
|
+
NodeTypes["JsonKeyValuePair"] = "JsonKeyValuePair";
|
|
52
55
|
// platformos markup types
|
|
53
56
|
NodeTypes["BackgroundMarkup"] = "BackgroundMarkup";
|
|
54
57
|
NodeTypes["BackgroundInlineMarkup"] = "BackgroundInlineMarkup";
|
|
@@ -79,12 +82,9 @@ var NamedTags;
|
|
|
79
82
|
NamedTags["increment"] = "increment";
|
|
80
83
|
NamedTags["layout"] = "layout";
|
|
81
84
|
NamedTags["liquid"] = "liquid";
|
|
82
|
-
NamedTags["paginate"] = "paginate";
|
|
83
85
|
NamedTags["render"] = "render";
|
|
84
86
|
NamedTags["function"] = "function";
|
|
85
87
|
NamedTags["graphql"] = "graphql";
|
|
86
|
-
NamedTags["section"] = "section";
|
|
87
|
-
NamedTags["sections"] = "sections";
|
|
88
88
|
NamedTags["tablerow"] = "tablerow";
|
|
89
89
|
NamedTags["unless"] = "unless";
|
|
90
90
|
NamedTags["when"] = "when";
|
package/grammar/liquid-html.ohm
CHANGED
|
@@ -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,18 +95,18 @@ 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
|
|
109
106
|
|
|
110
107
|
liquidTagOpenGraphQL = liquidTagOpenRule<"graphql", liquidTagGraphQLInlineMarkup>
|
|
111
108
|
// Use negative lookahead to exclude file-based syntax (with "=")
|
|
112
|
-
liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=")
|
|
109
|
+
liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=") graphqlRenderArguments
|
|
113
110
|
|
|
114
111
|
liquidTagOpen =
|
|
115
112
|
| liquidTagOpenStrict
|
|
@@ -129,7 +126,51 @@ Liquid <: Helpers {
|
|
|
129
126
|
liquidTagEchoMarkup = liquidVariable<delimTag>
|
|
130
127
|
|
|
131
128
|
liquidTagAssign = liquidTagRule<"assign", liquidTagAssignMarkup>
|
|
132
|
-
liquidTagAssignMarkup =
|
|
129
|
+
liquidTagAssignMarkup = assignTarget<delimTag> space* assignOperator space* liquidAssignValue<delimTag>
|
|
130
|
+
|
|
131
|
+
// Assign-specific sub-rules
|
|
132
|
+
assignTarget<delim> = variableSegment lookup<delim>*
|
|
133
|
+
assignOperator = "<<" | "="
|
|
134
|
+
|
|
135
|
+
// The RHS of an assign: either an explicit push expression (source << value) or a regular value
|
|
136
|
+
liquidAssignValue<delim> = liquidAssignPushExpr<delim> | liquidAssignVariable<delim>
|
|
137
|
+
|
|
138
|
+
// Explicit push: assign a = source << value (equivalent to assign a << value when source is a)
|
|
139
|
+
liquidAssignPushExpr<delim> = liquidAssignPushSource<delim> space* "<<" space* liquidAssignVariable<delim>
|
|
140
|
+
|
|
141
|
+
// The source expression for a push (no &delim lookahead since "<<" follows)
|
|
142
|
+
liquidAssignPushSource<delim> = liquidAssignExpression<delim> liquidFilter<delim>* space*
|
|
143
|
+
|
|
144
|
+
// Assign variable: like liquidVariable but expression allows JSON literals
|
|
145
|
+
liquidAssignVariable<delim> = liquidAssignExpression<delim> liquidFilter<delim>* space* &delim
|
|
146
|
+
liquidAssignExpression<delim> =
|
|
147
|
+
| liquidJsonHashLiteral<delim>
|
|
148
|
+
| liquidJsonArrayLiteral<delim>
|
|
149
|
+
| liquidComplexExpression<delim>
|
|
150
|
+
|
|
151
|
+
// JSON literal rules (assign-only, recursive)
|
|
152
|
+
liquidJsonHashLiteral<delim> =
|
|
153
|
+
"{" space* listOf<liquidJsonKeyValue<delim>, liquidJsonSep> space* "}"
|
|
154
|
+
liquidJsonKeyValue<delim> =
|
|
155
|
+
liquidJsonKey<delim> space* ":" space* liquidJsonValue<delim>
|
|
156
|
+
liquidJsonKey<delim> = liquidString<delim> | liquidJsonBareKey
|
|
157
|
+
liquidJsonBareKey = variableSegment
|
|
158
|
+
liquidJsonArrayLiteral<delim> =
|
|
159
|
+
"[" space* listOf<liquidJsonValue<delim>, liquidJsonSep> space* "]"
|
|
160
|
+
liquidJsonValue<delim> =
|
|
161
|
+
| liquidJsonHashLiteral<delim>
|
|
162
|
+
| liquidJsonArrayLiteral<delim>
|
|
163
|
+
| liquidJsonItemVariable<delim>
|
|
164
|
+
| liquidExpression<delim>
|
|
165
|
+
// Like liquidVariable but without &delim lookahead, so it works inside JSON structures.
|
|
166
|
+
// Requires at least one filter (liquidJsonFilter+) so plain expressions fall through to liquidExpression.
|
|
167
|
+
// Uses liquidJsonFilter (no trailing comma) instead of liquidFilter to avoid consuming the
|
|
168
|
+
// JSON entry separator comma (e.g. the "," in { "a": x | filter: arg, "b": y }).
|
|
169
|
+
liquidJsonItemVariable<delim> = liquidComplexExpression<delim> liquidJsonFilter<delim>+ space*
|
|
170
|
+
// Like liquidFilter but without the trailing (space* ",")? so commas between JSON entries
|
|
171
|
+
// are not consumed as trailing filter argument commas.
|
|
172
|
+
liquidJsonFilter<delim> = space* "|" space* identifier (space* ":" space* arguments<delim>)?
|
|
173
|
+
liquidJsonSep = space* "," space*
|
|
133
174
|
|
|
134
175
|
liquidTagHashAssign = liquidTagRule<"hash_assign", liquidTagHashAssignMarkup>
|
|
135
176
|
liquidTagHashAssignMarkup = liquidVariableLookup<delimTag> space* "=" space* liquidVariable<delimTag>
|
|
@@ -142,12 +183,6 @@ Liquid <: Helpers {
|
|
|
142
183
|
liquidTagOpenCapture = liquidTagOpenRule<"capture", variableSegmentAsLookupMarkup>
|
|
143
184
|
variableSegmentAsLookupMarkup = variableSegmentAsLookup space*
|
|
144
185
|
|
|
145
|
-
liquidTagSection = liquidTagRule<"section", liquidTagSectionMarkup>
|
|
146
|
-
liquidTagSectionMarkup = liquidString<delimTag> space*
|
|
147
|
-
|
|
148
|
-
liquidTagSections = liquidTagRule<"sections", liquidTagSectionsMarkup>
|
|
149
|
-
liquidTagSectionsMarkup = liquidString<delimTag> space*
|
|
150
|
-
|
|
151
186
|
liquidTagLayout = liquidTagRule<"layout", liquidTagLayoutMarkup>
|
|
152
187
|
liquidTagLayoutMarkup = liquidExpression<delimTag> space*
|
|
153
188
|
|
|
@@ -162,31 +197,24 @@ Liquid <: Helpers {
|
|
|
162
197
|
liquidTagLiquid = liquidTagRule<"liquid", liquidTagLiquidMarkup>
|
|
163
198
|
liquidTagLiquidMarkup = tagMarkup
|
|
164
199
|
|
|
165
|
-
|
|
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
|
-
|
|
200
|
+
liquidTagOpenContentFor = liquidTagOpenRule<"content_for", liquidTagContentForMarkup>
|
|
201
|
+
liquidTagContentForMarkup = contentForType space*
|
|
174
202
|
contentForType = liquidString<delimTag>
|
|
175
203
|
|
|
176
204
|
liquidTagInclude = liquidTagRule<"include", liquidTagRenderMarkup>
|
|
177
205
|
liquidTagRender = liquidTagRule<"render", liquidTagRenderMarkup>
|
|
178
206
|
liquidTagRenderMarkup =
|
|
179
|
-
|
|
207
|
+
partialExpression renderVariableExpression? renderAliasExpression? renderArguments
|
|
180
208
|
|
|
181
209
|
liquidTagFunction = liquidTagRule<"function", liquidTagFunctionMarkup>
|
|
182
|
-
liquidTagFunctionMarkup = variableSegment space* "=" space*
|
|
210
|
+
liquidTagFunctionMarkup = variableSegment space* "=" space* partialExpression renderArguments
|
|
183
211
|
|
|
184
212
|
liquidTagGraphQL = liquidTagRule<"graphql", liquidTagGraphQLMarkup>
|
|
185
|
-
liquidTagGraphQLMarkup = variableSegment space* "=" space*
|
|
213
|
+
liquidTagGraphQLMarkup = variableSegment space* "=" space* partialExpression graphqlRenderArguments
|
|
186
214
|
|
|
187
215
|
// platformos simple tags
|
|
188
216
|
liquidTagBackground = liquidTagRule<"background", liquidTagBackgroundMarkup>
|
|
189
|
-
liquidTagBackgroundMarkup = variableSegment space* "=" space*
|
|
217
|
+
liquidTagBackgroundMarkup = variableSegment space* "=" space* partialExpression renderArguments
|
|
190
218
|
|
|
191
219
|
liquidTagOpenBackground = liquidTagOpenRule<"background", liquidTagBackgroundInlineMarkup>
|
|
192
220
|
// Use negative lookahead to exclude file-based syntax (with "=")
|
|
@@ -233,7 +261,7 @@ Liquid <: Helpers {
|
|
|
233
261
|
liquidTagRedirectToMarkup = liquidExpression<delimTag> renderArguments
|
|
234
262
|
|
|
235
263
|
liquidTagIncludeForm = liquidTagRule<"include_form", liquidTagIncludeFormMarkup>
|
|
236
|
-
liquidTagIncludeFormMarkup =
|
|
264
|
+
liquidTagIncludeFormMarkup = partialExpression renderArguments
|
|
237
265
|
|
|
238
266
|
liquidTagSpamProtection = liquidTagRule<"spam_protection", liquidTagSpamProtectionMarkup>
|
|
239
267
|
liquidTagSpamProtectionMarkup = liquidExpression<delimTag> renderArguments
|
|
@@ -250,7 +278,6 @@ Liquid <: Helpers {
|
|
|
250
278
|
|
|
251
279
|
renderArguments = (argumentSeparatorOptionalComma tagArguments) (space* ",")? space*
|
|
252
280
|
completionModeRenderArguments = (argumentSeparatorOptionalComma tagArguments) (space* ",")? space* (argumentSeparator? liquidVariableLookup<delimTag> space*)?
|
|
253
|
-
snippetExpression = liquidString<delimTag> | variableSegmentAsLookup
|
|
254
281
|
partialExpression = liquidString<delimTag> | variableSegmentAsLookup
|
|
255
282
|
renderVariableExpression = space+ ("for" | "with") space+ liquidExpression<delimTag>
|
|
256
283
|
renderAliasExpression = space+ "as" space+ variableSegment
|
|
@@ -259,7 +286,6 @@ Liquid <: Helpers {
|
|
|
259
286
|
liquidTagOpenBaseCase = liquidTagOpenRule<blockNameNotSpecial, tagMarkup>
|
|
260
287
|
blockNameNotSpecial =
|
|
261
288
|
( "form"
|
|
262
|
-
| "paginate"
|
|
263
289
|
| "capture"
|
|
264
290
|
| "case"
|
|
265
291
|
| "for"
|
|
@@ -278,6 +304,7 @@ Liquid <: Helpers {
|
|
|
278
304
|
liquidTagOpenFormMarkup = arguments<delimTag> (space* ",")? space*
|
|
279
305
|
|
|
280
306
|
liquidTagOpenFor = liquidTagOpenRule<"for", liquidTagOpenForMarkup>
|
|
307
|
+
|
|
281
308
|
liquidTagOpenForMarkup =
|
|
282
309
|
variableSegment space* "in" space* liquidExpression<delimTag>
|
|
283
310
|
(space* "reversed")? argumentSeparatorOptionalComma
|
|
@@ -312,13 +339,9 @@ Liquid <: Helpers {
|
|
|
312
339
|
| ">="
|
|
313
340
|
| "<="
|
|
314
341
|
| ">"
|
|
315
|
-
| "<")
|
|
342
|
+
| "<" ~"<")
|
|
316
343
|
| ("contains" ~identifier)
|
|
317
344
|
|
|
318
|
-
liquidTagOpenPaginate = liquidTagOpenRule<"paginate", liquidTagOpenPaginateMarkup>
|
|
319
|
-
liquidTagOpenPaginateMarkup =
|
|
320
|
-
liquidExpression<delimTag> space+ "by" space+ liquidExpression<delimTag> argumentSeparatorOptionalComma tagArguments (space* ",")? space*
|
|
321
|
-
|
|
322
345
|
liquidDrop = "{{" "-"? space* liquidDropCases "-"? "}}"
|
|
323
346
|
liquidDropCases = liquidVariable<delimVO> | liquidDropBaseCase
|
|
324
347
|
liquidDropBaseCase = anyExceptStar<delimVO>
|
|
@@ -326,10 +349,6 @@ Liquid <: Helpers {
|
|
|
326
349
|
|
|
327
350
|
liquidRawTag =
|
|
328
351
|
| liquidRawTagImpl<"raw">
|
|
329
|
-
| liquidRawTagImpl<"javascript">
|
|
330
|
-
| liquidRawTagImpl<"schema">
|
|
331
|
-
| liquidRawTagImpl<"stylesheet">
|
|
332
|
-
| liquidRawTagImpl<"style">
|
|
333
352
|
liquidRawTagImpl<name> =
|
|
334
353
|
"{%" "-"? space* (name endOfIdentifier) space* tagMarkup "-"? "%}"
|
|
335
354
|
anyExceptStar<liquidRawTagClose<name>>
|
|
@@ -418,6 +437,10 @@ Liquid <: Helpers {
|
|
|
418
437
|
positionalArgument<delim> = liquidExpression<delim> ~(space* ":")
|
|
419
438
|
namedArgument<delim> = variableSegment space* ":" space* liquidExpression<delim>
|
|
420
439
|
tagArguments = listOf<namedArgument<delimTag>, argumentSeparatorOptionalComma>
|
|
440
|
+
graphqlArguments = listOf<graphqlNamedArgument, argumentSeparatorOptionalComma>
|
|
441
|
+
graphqlNamedArgument = variableSegment space* ":" space* graphqlNamedArgumentValue
|
|
442
|
+
graphqlNamedArgumentValue = liquidExpression<delimTag> liquidFilter<delimTag>*
|
|
443
|
+
graphqlRenderArguments = (argumentSeparatorOptionalComma graphqlArguments) (space* ",")? space*
|
|
421
444
|
filterArguments<delim> =
|
|
422
445
|
| complexArguments<delim>
|
|
423
446
|
| simpleArgument<delim>
|
|
@@ -434,9 +457,7 @@ Liquid <: Helpers {
|
|
|
434
457
|
letter (alnum | "_")*
|
|
435
458
|
|
|
436
459
|
blockName =
|
|
437
|
-
// Shopify blocks
|
|
438
460
|
( "form"
|
|
439
|
-
| "paginate"
|
|
440
461
|
// Base blocks
|
|
441
462
|
| "capture"
|
|
442
463
|
| "case"
|
|
@@ -449,6 +470,7 @@ Liquid <: Helpers {
|
|
|
449
470
|
// platformos blocks
|
|
450
471
|
| "background"
|
|
451
472
|
| "cache"
|
|
473
|
+
| "content_for"
|
|
452
474
|
| "parse_json"
|
|
453
475
|
| "transaction"
|
|
454
476
|
| "try"
|
|
@@ -707,10 +729,8 @@ StrictLiquidHTML <: LiquidHTML {
|
|
|
707
729
|
|
|
708
730
|
WithPlaceholderLiquid <: Liquid {
|
|
709
731
|
liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
|
|
710
|
-
liquidTagContentForMarkup :=
|
|
711
|
-
contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
|
|
712
732
|
liquidTagRenderMarkup :=
|
|
713
|
-
|
|
733
|
+
partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
|
|
714
734
|
liquidTagName := (letter | "█") (alnum | "_")*
|
|
715
735
|
variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
|
|
716
736
|
liquidDoc :=
|
|
@@ -721,10 +741,8 @@ WithPlaceholderLiquid <: Liquid {
|
|
|
721
741
|
|
|
722
742
|
WithPlaceholderLiquidStatement <: LiquidStatement {
|
|
723
743
|
liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
|
|
724
|
-
liquidTagContentForMarkup :=
|
|
725
|
-
contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
|
|
726
744
|
liquidTagRenderMarkup :=
|
|
727
|
-
|
|
745
|
+
partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
|
|
728
746
|
liquidTagName := (letter | "█") (alnum | "_")*
|
|
729
747
|
variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
|
|
730
748
|
liquidDoc :=
|
|
@@ -735,10 +753,8 @@ WithPlaceholderLiquidStatement <: LiquidStatement {
|
|
|
735
753
|
|
|
736
754
|
WithPlaceholderLiquidHTML <: LiquidHTML {
|
|
737
755
|
liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
|
|
738
|
-
liquidTagContentForMarkup :=
|
|
739
|
-
contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
|
|
740
756
|
liquidTagRenderMarkup :=
|
|
741
|
-
|
|
757
|
+
partialExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
|
|
742
758
|
liquidTagName := (letter | "█") (alnum | "_")*
|
|
743
759
|
variableSegment := (letter | "_" | "█") (identifierCharacter | "█")*
|
|
744
760
|
leadingTagNameTextNode := (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,18 +95,18 @@ 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
|
|
109
106
|
|
|
110
107
|
liquidTagOpenGraphQL = liquidTagOpenRule<"graphql", liquidTagGraphQLInlineMarkup>
|
|
111
108
|
// Use negative lookahead to exclude file-based syntax (with "=")
|
|
112
|
-
liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=")
|
|
109
|
+
liquidTagGraphQLInlineMarkup = variableSegment ~(space* "=") graphqlRenderArguments
|
|
113
110
|
|
|
114
111
|
liquidTagOpen =
|
|
115
112
|
| liquidTagOpenStrict
|
|
@@ -129,7 +126,51 @@ Liquid <: Helpers {
|
|
|
129
126
|
liquidTagEchoMarkup = liquidVariable<delimTag>
|
|
130
127
|
|
|
131
128
|
liquidTagAssign = liquidTagRule<"assign", liquidTagAssignMarkup>
|
|
132
|
-
liquidTagAssignMarkup =
|
|
129
|
+
liquidTagAssignMarkup = assignTarget<delimTag> space* assignOperator space* liquidAssignValue<delimTag>
|
|
130
|
+
|
|
131
|
+
// Assign-specific sub-rules
|
|
132
|
+
assignTarget<delim> = variableSegment lookup<delim>*
|
|
133
|
+
assignOperator = "<<" | "="
|
|
134
|
+
|
|
135
|
+
// The RHS of an assign: either an explicit push expression (source << value) or a regular value
|
|
136
|
+
liquidAssignValue<delim> = liquidAssignPushExpr<delim> | liquidAssignVariable<delim>
|
|
137
|
+
|
|
138
|
+
// Explicit push: assign a = source << value (equivalent to assign a << value when source is a)
|
|
139
|
+
liquidAssignPushExpr<delim> = liquidAssignPushSource<delim> space* "<<" space* liquidAssignVariable<delim>
|
|
140
|
+
|
|
141
|
+
// The source expression for a push (no &delim lookahead since "<<" follows)
|
|
142
|
+
liquidAssignPushSource<delim> = liquidAssignExpression<delim> liquidFilter<delim>* space*
|
|
143
|
+
|
|
144
|
+
// Assign variable: like liquidVariable but expression allows JSON literals
|
|
145
|
+
liquidAssignVariable<delim> = liquidAssignExpression<delim> liquidFilter<delim>* space* &delim
|
|
146
|
+
liquidAssignExpression<delim> =
|
|
147
|
+
| liquidJsonHashLiteral<delim>
|
|
148
|
+
| liquidJsonArrayLiteral<delim>
|
|
149
|
+
| liquidComplexExpression<delim>
|
|
150
|
+
|
|
151
|
+
// JSON literal rules (assign-only, recursive)
|
|
152
|
+
liquidJsonHashLiteral<delim> =
|
|
153
|
+
"{" space* listOf<liquidJsonKeyValue<delim>, liquidJsonSep> space* "}"
|
|
154
|
+
liquidJsonKeyValue<delim> =
|
|
155
|
+
liquidJsonKey<delim> space* ":" space* liquidJsonValue<delim>
|
|
156
|
+
liquidJsonKey<delim> = liquidString<delim> | liquidJsonBareKey
|
|
157
|
+
liquidJsonBareKey = variableSegment
|
|
158
|
+
liquidJsonArrayLiteral<delim> =
|
|
159
|
+
"[" space* listOf<liquidJsonValue<delim>, liquidJsonSep> space* "]"
|
|
160
|
+
liquidJsonValue<delim> =
|
|
161
|
+
| liquidJsonHashLiteral<delim>
|
|
162
|
+
| liquidJsonArrayLiteral<delim>
|
|
163
|
+
| liquidJsonItemVariable<delim>
|
|
164
|
+
| liquidExpression<delim>
|
|
165
|
+
// Like liquidVariable but without &delim lookahead, so it works inside JSON structures.
|
|
166
|
+
// Requires at least one filter (liquidJsonFilter+) so plain expressions fall through to liquidExpression.
|
|
167
|
+
// Uses liquidJsonFilter (no trailing comma) instead of liquidFilter to avoid consuming the
|
|
168
|
+
// JSON entry separator comma (e.g. the "," in { "a": x | filter: arg, "b": y }).
|
|
169
|
+
liquidJsonItemVariable<delim> = liquidComplexExpression<delim> liquidJsonFilter<delim>+ space*
|
|
170
|
+
// Like liquidFilter but without the trailing (space* ",")? so commas between JSON entries
|
|
171
|
+
// are not consumed as trailing filter argument commas.
|
|
172
|
+
liquidJsonFilter<delim> = space* "|" space* identifier (space* ":" space* arguments<delim>)?
|
|
173
|
+
liquidJsonSep = space* "," space*
|
|
133
174
|
|
|
134
175
|
liquidTagHashAssign = liquidTagRule<"hash_assign", liquidTagHashAssignMarkup>
|
|
135
176
|
liquidTagHashAssignMarkup = liquidVariableLookup<delimTag> space* "=" space* liquidVariable<delimTag>
|
|
@@ -142,12 +183,6 @@ Liquid <: Helpers {
|
|
|
142
183
|
liquidTagOpenCapture = liquidTagOpenRule<"capture", variableSegmentAsLookupMarkup>
|
|
143
184
|
variableSegmentAsLookupMarkup = variableSegmentAsLookup space*
|
|
144
185
|
|
|
145
|
-
liquidTagSection = liquidTagRule<"section", liquidTagSectionMarkup>
|
|
146
|
-
liquidTagSectionMarkup = liquidString<delimTag> space*
|
|
147
|
-
|
|
148
|
-
liquidTagSections = liquidTagRule<"sections", liquidTagSectionsMarkup>
|
|
149
|
-
liquidTagSectionsMarkup = liquidString<delimTag> space*
|
|
150
|
-
|
|
151
186
|
liquidTagLayout = liquidTagRule<"layout", liquidTagLayoutMarkup>
|
|
152
187
|
liquidTagLayoutMarkup = liquidExpression<delimTag> space*
|
|
153
188
|
|
|
@@ -162,15 +197,8 @@ Liquid <: Helpers {
|
|
|
162
197
|
liquidTagLiquid = liquidTagRule<"liquid", liquidTagLiquidMarkup>
|
|
163
198
|
liquidTagLiquidMarkup = tagMarkup
|
|
164
199
|
|
|
165
|
-
|
|
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
|
-
|
|
200
|
+
liquidTagOpenContentFor = liquidTagOpenRule<"content_for", liquidTagContentForMarkup>
|
|
201
|
+
liquidTagContentForMarkup = contentForType space*
|
|
174
202
|
contentForType = liquidString<delimTag>
|
|
175
203
|
|
|
176
204
|
liquidTagInclude = liquidTagRule<"include", liquidTagRenderMarkup>
|
|
@@ -182,7 +210,7 @@ Liquid <: Helpers {
|
|
|
182
210
|
liquidTagFunctionMarkup = variableSegment space* "=" space* snippetExpression renderArguments
|
|
183
211
|
|
|
184
212
|
liquidTagGraphQL = liquidTagRule<"graphql", liquidTagGraphQLMarkup>
|
|
185
|
-
liquidTagGraphQLMarkup = variableSegment space* "=" space* snippetExpression
|
|
213
|
+
liquidTagGraphQLMarkup = variableSegment space* "=" space* snippetExpression graphqlRenderArguments
|
|
186
214
|
|
|
187
215
|
// platformos simple tags
|
|
188
216
|
liquidTagBackground = liquidTagRule<"background", liquidTagBackgroundMarkup>
|
|
@@ -259,7 +287,6 @@ Liquid <: Helpers {
|
|
|
259
287
|
liquidTagOpenBaseCase = liquidTagOpenRule<blockNameNotSpecial, tagMarkup>
|
|
260
288
|
blockNameNotSpecial =
|
|
261
289
|
( "form"
|
|
262
|
-
| "paginate"
|
|
263
290
|
| "capture"
|
|
264
291
|
| "case"
|
|
265
292
|
| "for"
|
|
@@ -278,6 +305,7 @@ Liquid <: Helpers {
|
|
|
278
305
|
liquidTagOpenFormMarkup = arguments<delimTag> (space* ",")? space*
|
|
279
306
|
|
|
280
307
|
liquidTagOpenFor = liquidTagOpenRule<"for", liquidTagOpenForMarkup>
|
|
308
|
+
|
|
281
309
|
liquidTagOpenForMarkup =
|
|
282
310
|
variableSegment space* "in" space* liquidExpression<delimTag>
|
|
283
311
|
(space* "reversed")? argumentSeparatorOptionalComma
|
|
@@ -312,13 +340,9 @@ Liquid <: Helpers {
|
|
|
312
340
|
| ">="
|
|
313
341
|
| "<="
|
|
314
342
|
| ">"
|
|
315
|
-
| "<")
|
|
343
|
+
| "<" ~"<")
|
|
316
344
|
| ("contains" ~identifier)
|
|
317
345
|
|
|
318
|
-
liquidTagOpenPaginate = liquidTagOpenRule<"paginate", liquidTagOpenPaginateMarkup>
|
|
319
|
-
liquidTagOpenPaginateMarkup =
|
|
320
|
-
liquidExpression<delimTag> space+ "by" space+ liquidExpression<delimTag> argumentSeparatorOptionalComma tagArguments (space* ",")? space*
|
|
321
|
-
|
|
322
346
|
liquidDrop = "{{" "-"? space* liquidDropCases "-"? "}}"
|
|
323
347
|
liquidDropCases = liquidVariable<delimVO> | liquidDropBaseCase
|
|
324
348
|
liquidDropBaseCase = anyExceptStar<delimVO>
|
|
@@ -326,10 +350,6 @@ Liquid <: Helpers {
|
|
|
326
350
|
|
|
327
351
|
liquidRawTag =
|
|
328
352
|
| liquidRawTagImpl<"raw">
|
|
329
|
-
| liquidRawTagImpl<"javascript">
|
|
330
|
-
| liquidRawTagImpl<"schema">
|
|
331
|
-
| liquidRawTagImpl<"stylesheet">
|
|
332
|
-
| liquidRawTagImpl<"style">
|
|
333
353
|
liquidRawTagImpl<name> =
|
|
334
354
|
"{%" "-"? space* (name endOfIdentifier) space* tagMarkup "-"? "%}"
|
|
335
355
|
anyExceptStar<liquidRawTagClose<name>>
|
|
@@ -418,6 +438,10 @@ Liquid <: Helpers {
|
|
|
418
438
|
positionalArgument<delim> = liquidExpression<delim> ~(space* ":")
|
|
419
439
|
namedArgument<delim> = variableSegment space* ":" space* liquidExpression<delim>
|
|
420
440
|
tagArguments = listOf<namedArgument<delimTag>, argumentSeparatorOptionalComma>
|
|
441
|
+
graphqlArguments = listOf<graphqlNamedArgument, argumentSeparatorOptionalComma>
|
|
442
|
+
graphqlNamedArgument = variableSegment space* ":" space* graphqlNamedArgumentValue
|
|
443
|
+
graphqlNamedArgumentValue = liquidExpression<delimTag> liquidFilter<delimTag>*
|
|
444
|
+
graphqlRenderArguments = (argumentSeparatorOptionalComma graphqlArguments) (space* ",")? space*
|
|
421
445
|
filterArguments<delim> =
|
|
422
446
|
| complexArguments<delim>
|
|
423
447
|
| simpleArgument<delim>
|
|
@@ -434,9 +458,7 @@ Liquid <: Helpers {
|
|
|
434
458
|
letter (alnum | "_")*
|
|
435
459
|
|
|
436
460
|
blockName =
|
|
437
|
-
// Shopify blocks
|
|
438
461
|
( "form"
|
|
439
|
-
| "paginate"
|
|
440
462
|
// Base blocks
|
|
441
463
|
| "capture"
|
|
442
464
|
| "case"
|
|
@@ -449,6 +471,7 @@ Liquid <: Helpers {
|
|
|
449
471
|
// platformos blocks
|
|
450
472
|
| "background"
|
|
451
473
|
| "cache"
|
|
474
|
+
| "content_for"
|
|
452
475
|
| "parse_json"
|
|
453
476
|
| "transaction"
|
|
454
477
|
| "try"
|
|
@@ -707,8 +730,6 @@ StrictLiquidHTML <: LiquidHTML {
|
|
|
707
730
|
|
|
708
731
|
WithPlaceholderLiquid <: Liquid {
|
|
709
732
|
liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
|
|
710
|
-
liquidTagContentForMarkup :=
|
|
711
|
-
contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
|
|
712
733
|
liquidTagRenderMarkup :=
|
|
713
734
|
snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
|
|
714
735
|
liquidTagName := (letter | "█") (alnum | "_")*
|
|
@@ -721,8 +742,6 @@ WithPlaceholderLiquid <: Liquid {
|
|
|
721
742
|
|
|
722
743
|
WithPlaceholderLiquidStatement <: LiquidStatement {
|
|
723
744
|
liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
|
|
724
|
-
liquidTagContentForMarkup :=
|
|
725
|
-
contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
|
|
726
745
|
liquidTagRenderMarkup :=
|
|
727
746
|
snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
|
|
728
747
|
liquidTagName := (letter | "█") (alnum | "_")*
|
|
@@ -735,8 +754,6 @@ WithPlaceholderLiquidStatement <: LiquidStatement {
|
|
|
735
754
|
|
|
736
755
|
WithPlaceholderLiquidHTML <: LiquidHTML {
|
|
737
756
|
liquidFilter<delim> := space* "|" space* identifier (space* ":" space* filterArguments<delim> (space* ",")?)?
|
|
738
|
-
liquidTagContentForMarkup :=
|
|
739
|
-
contentForType (argumentSeparatorOptionalComma completionModeContentForTagArgument) (space* ",")? space*
|
|
740
757
|
liquidTagRenderMarkup :=
|
|
741
758
|
snippetExpression renderVariableExpression? renderAliasExpression? completionModeRenderArguments
|
|
742
759
|
liquidTagName := (letter | "█") (alnum | "_")*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformos/liquid-html-parser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
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",
|