@skeptools/skep-organization-project 0.0.15 → 0.0.17
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/.jsii +138 -3
- package/API.md +137 -44
- package/lib/skep-organization-project.js +1 -1
- package/node_modules/liquidjs/README.md +29 -17
- package/node_modules/liquidjs/dist/context/context.d.ts +13 -4
- package/node_modules/liquidjs/dist/drop/blank-drop.d.ts +1 -0
- package/node_modules/liquidjs/dist/drop/drop.d.ts +1 -1
- package/node_modules/liquidjs/dist/drop/empty-drop.d.ts +1 -0
- package/node_modules/liquidjs/dist/filters/array.d.ts +14 -14
- package/node_modules/liquidjs/dist/filters/html.d.ts +6 -5
- package/node_modules/liquidjs/dist/filters/math.d.ts +9 -9
- package/node_modules/liquidjs/dist/filters/string.d.ts +22 -21
- package/node_modules/liquidjs/dist/fs/map-fs.d.ts +13 -0
- package/node_modules/liquidjs/dist/fs/node-require.d.ts +1 -2
- package/node_modules/liquidjs/dist/index.d.ts +3 -3
- package/node_modules/liquidjs/dist/liquid-options.d.ts +30 -2
- package/node_modules/liquidjs/dist/liquid.browser.min.js +1 -1
- package/node_modules/liquidjs/dist/liquid.browser.min.js.map +1 -1
- package/node_modules/liquidjs/dist/{liquid.browser.esm.js → liquid.browser.mjs} +1147 -264
- package/node_modules/liquidjs/dist/liquid.browser.umd.js +2072 -478
- package/node_modules/liquidjs/dist/liquid.browser.umd.js.map +1 -1
- package/node_modules/liquidjs/dist/liquid.d.ts +32 -1
- package/node_modules/liquidjs/dist/{liquid.node.cjs.js → liquid.node.js} +1123 -264
- package/node_modules/liquidjs/dist/{liquid.node.esm.js → liquid.node.mjs} +1152 -265
- package/node_modules/liquidjs/dist/parser/parser.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/parser.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/parser/tokenizer.d.ts +4 -3
- package/node_modules/liquidjs/dist/render/expression.d.ts +1 -1
- package/node_modules/liquidjs/dist/render/operator.d.ts +1 -0
- package/node_modules/liquidjs/dist/tags/assign.d.ts +5 -0
- package/node_modules/liquidjs/dist/tags/block.d.ts +4 -1
- package/node_modules/liquidjs/dist/tags/break.d.ts +1 -1
- package/node_modules/liquidjs/dist/tags/capture.d.ts +7 -2
- package/node_modules/liquidjs/dist/tags/case.d.ts +5 -1
- package/node_modules/liquidjs/dist/tags/continue.d.ts +1 -1
- package/node_modules/liquidjs/dist/tags/cycle.d.ts +2 -0
- package/node_modules/liquidjs/dist/tags/decrement.d.ts +3 -0
- package/node_modules/liquidjs/dist/tags/echo.d.ts +2 -0
- package/node_modules/liquidjs/dist/tags/for.d.ts +6 -1
- package/node_modules/liquidjs/dist/tags/if.d.ts +6 -2
- package/node_modules/liquidjs/dist/tags/include.d.ts +7 -2
- package/node_modules/liquidjs/dist/tags/increment.d.ts +3 -0
- package/node_modules/liquidjs/dist/tags/layout.d.ts +6 -1
- package/node_modules/liquidjs/dist/tags/liquid.d.ts +3 -1
- package/node_modules/liquidjs/dist/tags/render.d.ts +7 -2
- package/node_modules/liquidjs/dist/tags/tablerow.d.ts +6 -1
- package/node_modules/liquidjs/dist/tags/unless.d.ts +5 -1
- package/node_modules/liquidjs/dist/template/analysis.d.ts +85 -0
- package/node_modules/liquidjs/dist/template/analysis.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/template/filter-impl-options.d.ts +2 -0
- package/node_modules/liquidjs/dist/template/filter.d.ts +3 -1
- package/node_modules/liquidjs/dist/template/hash.d.ts +2 -1
- package/node_modules/liquidjs/dist/template/index.d.ts +1 -0
- package/node_modules/liquidjs/dist/template/output.d.ts +2 -1
- package/node_modules/liquidjs/dist/template/tag.d.ts +2 -2
- package/node_modules/liquidjs/dist/template/template.d.ts +29 -0
- package/node_modules/liquidjs/dist/tokens/identifier-token.d.ts +0 -1
- package/node_modules/liquidjs/dist/tokens/liquid-tag-token.d.ts +1 -1
- package/node_modules/liquidjs/dist/util/assert.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/error.d.ts +7 -2
- package/node_modules/liquidjs/dist/util/error.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/index.d.ts +2 -1
- package/node_modules/liquidjs/dist/util/intl.d.ts +6 -0
- package/node_modules/liquidjs/dist/util/limiter.d.ts +8 -0
- package/node_modules/liquidjs/dist/util/liquid-date.d.ts +39 -7
- package/node_modules/liquidjs/dist/util/liquid-date.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/performance.d.ts +5 -0
- package/node_modules/liquidjs/dist/util/performance.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/type-guards.d.ts +2 -1
- package/node_modules/liquidjs/dist/util/type-guards.spec.d.ts +1 -0
- package/node_modules/liquidjs/dist/util/underscore.d.ts +5 -1
- package/node_modules/liquidjs/package.json +11 -7
- package/package.json +17 -13
- package/node_modules/liquidjs/dist/util/timezone-date.d.ts +0 -44
- /package/node_modules/liquidjs/dist/{util/timezone-date.spec.d.ts → fs/map-fs.spec.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* liquidjs@10.
|
|
3
|
-
* (c) 2016-
|
|
2
|
+
* liquidjs@10.20.1, https://github.com/harttle/liquidjs
|
|
3
|
+
* (c) 2016-2025 harttle
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -218,6 +218,10 @@
|
|
|
218
218
|
function toValue(value) {
|
|
219
219
|
return (value instanceof Drop && isFunction(value.valueOf)) ? value.valueOf() : value;
|
|
220
220
|
}
|
|
221
|
+
function toNumber(value) {
|
|
222
|
+
value = Number(value);
|
|
223
|
+
return isNaN(value) ? 0 : value;
|
|
224
|
+
}
|
|
221
225
|
function isNumber(value) {
|
|
222
226
|
return typeof value === 'number';
|
|
223
227
|
}
|
|
@@ -236,6 +240,9 @@
|
|
|
236
240
|
// be compatible with IE 8
|
|
237
241
|
return toString$1.call(value) === '[object Array]';
|
|
238
242
|
}
|
|
243
|
+
function isArrayLike(value) {
|
|
244
|
+
return value && isNumber(value.length);
|
|
245
|
+
}
|
|
239
246
|
function isIterable(value) {
|
|
240
247
|
return isObject(value) && Symbol.iterator in value;
|
|
241
248
|
}
|
|
@@ -325,15 +332,56 @@
|
|
|
325
332
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
326
333
|
args[_i] = arguments[_i];
|
|
327
334
|
}
|
|
328
|
-
return fn.apply(
|
|
335
|
+
return fn.call.apply(fn, __spreadArray([this], __read(args.map(toValue)), false));
|
|
329
336
|
};
|
|
330
337
|
}
|
|
331
338
|
function escapeRegExp(text) {
|
|
332
339
|
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
340
|
+
}
|
|
341
|
+
/** Return an array containing unique elements from _array_. Works with nested arrays and objects. */
|
|
342
|
+
function strictUniq(array) {
|
|
343
|
+
var seen, array_1, array_1_1, element, key, e_1_1;
|
|
344
|
+
var e_1, _a;
|
|
345
|
+
return __generator(this, function (_b) {
|
|
346
|
+
switch (_b.label) {
|
|
347
|
+
case 0:
|
|
348
|
+
seen = new Set();
|
|
349
|
+
_b.label = 1;
|
|
350
|
+
case 1:
|
|
351
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
352
|
+
array_1 = __values(array), array_1_1 = array_1.next();
|
|
353
|
+
_b.label = 2;
|
|
354
|
+
case 2:
|
|
355
|
+
if (!!array_1_1.done) return [3 /*break*/, 5];
|
|
356
|
+
element = array_1_1.value;
|
|
357
|
+
key = JSON.stringify(element);
|
|
358
|
+
if (!!seen.has(key)) return [3 /*break*/, 4];
|
|
359
|
+
seen.add(key);
|
|
360
|
+
return [4 /*yield*/, element];
|
|
361
|
+
case 3:
|
|
362
|
+
_b.sent();
|
|
363
|
+
_b.label = 4;
|
|
364
|
+
case 4:
|
|
365
|
+
array_1_1 = array_1.next();
|
|
366
|
+
return [3 /*break*/, 2];
|
|
367
|
+
case 5: return [3 /*break*/, 8];
|
|
368
|
+
case 6:
|
|
369
|
+
e_1_1 = _b.sent();
|
|
370
|
+
e_1 = { error: e_1_1 };
|
|
371
|
+
return [3 /*break*/, 8];
|
|
372
|
+
case 7:
|
|
373
|
+
try {
|
|
374
|
+
if (array_1_1 && !array_1_1.done && (_a = array_1.return)) _a.call(array_1);
|
|
375
|
+
}
|
|
376
|
+
finally { if (e_1) throw e_1.error; }
|
|
377
|
+
return [7 /*endfinally*/];
|
|
378
|
+
case 8: return [2 /*return*/];
|
|
379
|
+
}
|
|
380
|
+
});
|
|
333
381
|
}
|
|
334
382
|
|
|
335
383
|
/**
|
|
336
|
-
* targeting ES5, extends Error won't create a proper prototype chain, need a trait to
|
|
384
|
+
* targeting ES5, extends Error won't create a proper prototype chain, need a trait to keep track of classes
|
|
337
385
|
*/
|
|
338
386
|
var TRAIT = '__liquidClass__';
|
|
339
387
|
var LiquidError = /** @class */ (function (_super) {
|
|
@@ -400,6 +448,22 @@
|
|
|
400
448
|
};
|
|
401
449
|
return RenderError;
|
|
402
450
|
}(LiquidError));
|
|
451
|
+
var LiquidErrors = /** @class */ (function (_super) {
|
|
452
|
+
__extends(LiquidErrors, _super);
|
|
453
|
+
function LiquidErrors(errors) {
|
|
454
|
+
var _this = _super.call(this, errors[0], errors[0].token) || this;
|
|
455
|
+
_this.errors = errors;
|
|
456
|
+
_this.name = 'LiquidErrors';
|
|
457
|
+
var s = errors.length > 1 ? 's' : '';
|
|
458
|
+
_this.message = "".concat(errors.length, " error").concat(s, " found");
|
|
459
|
+
_super.prototype.update.call(_this);
|
|
460
|
+
return _this;
|
|
461
|
+
}
|
|
462
|
+
LiquidErrors.is = function (obj) {
|
|
463
|
+
return obj.name === 'LiquidErrors';
|
|
464
|
+
};
|
|
465
|
+
return LiquidErrors;
|
|
466
|
+
}(LiquidError));
|
|
403
467
|
var UndefinedVariableError = /** @class */ (function (_super) {
|
|
404
468
|
__extends(UndefinedVariableError, _super);
|
|
405
469
|
function UndefinedVariableError(err, token) {
|
|
@@ -487,6 +551,10 @@
|
|
|
487
551
|
: (message || "expect ".concat(predicate, " to be true"));
|
|
488
552
|
throw new AssertionError(msg);
|
|
489
553
|
}
|
|
554
|
+
}
|
|
555
|
+
function assertEmpty(predicate, message) {
|
|
556
|
+
if (message === void 0) { message = "unexpected ".concat(JSON.stringify(predicate)); }
|
|
557
|
+
assert(!predicate, message);
|
|
490
558
|
}
|
|
491
559
|
|
|
492
560
|
var NullDrop = /** @class */ (function (_super) {
|
|
@@ -545,6 +613,9 @@
|
|
|
545
613
|
EmptyDrop.prototype.valueOf = function () {
|
|
546
614
|
return '';
|
|
547
615
|
};
|
|
616
|
+
EmptyDrop.is = function (value) {
|
|
617
|
+
return value instanceof EmptyDrop;
|
|
618
|
+
};
|
|
548
619
|
return EmptyDrop;
|
|
549
620
|
}(Drop));
|
|
550
621
|
|
|
@@ -562,6 +633,9 @@
|
|
|
562
633
|
return /^\s*$/.test(value);
|
|
563
634
|
return _super.prototype.equals.call(this, value);
|
|
564
635
|
};
|
|
636
|
+
BlankDrop.is = function (value) {
|
|
637
|
+
return value instanceof BlankDrop;
|
|
638
|
+
};
|
|
565
639
|
return BlankDrop;
|
|
566
640
|
}(EmptyDrop));
|
|
567
641
|
|
|
@@ -622,7 +696,12 @@
|
|
|
622
696
|
}(Drop));
|
|
623
697
|
|
|
624
698
|
function isComparable(arg) {
|
|
625
|
-
return arg &&
|
|
699
|
+
return (arg &&
|
|
700
|
+
isFunction(arg.equals) &&
|
|
701
|
+
isFunction(arg.gt) &&
|
|
702
|
+
isFunction(arg.geq) &&
|
|
703
|
+
isFunction(arg.lt) &&
|
|
704
|
+
isFunction(arg.leq));
|
|
626
705
|
}
|
|
627
706
|
|
|
628
707
|
var nil = new NullDrop();
|
|
@@ -731,18 +810,6 @@
|
|
|
731
810
|
}
|
|
732
811
|
|
|
733
812
|
var rFormat = /%([-_0^#:]+)?(\d+)?([EO])?(.)/;
|
|
734
|
-
var monthNames = [
|
|
735
|
-
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
|
|
736
|
-
'September', 'October', 'November', 'December'
|
|
737
|
-
];
|
|
738
|
-
var dayNames = [
|
|
739
|
-
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
|
|
740
|
-
];
|
|
741
|
-
var monthNamesShort = monthNames.map(abbr);
|
|
742
|
-
var dayNamesShort = dayNames.map(abbr);
|
|
743
|
-
function abbr(str) {
|
|
744
|
-
return str.slice(0, 3);
|
|
745
|
-
}
|
|
746
813
|
// prototype extensions
|
|
747
814
|
function daysInMonth(d) {
|
|
748
815
|
var feb = isLeapYear(d) ? 29 : 28;
|
|
@@ -797,19 +864,7 @@
|
|
|
797
864
|
U: 2,
|
|
798
865
|
W: 2
|
|
799
866
|
};
|
|
800
|
-
|
|
801
|
-
var padChars = {
|
|
802
|
-
a: ' ',
|
|
803
|
-
A: ' ',
|
|
804
|
-
b: ' ',
|
|
805
|
-
B: ' ',
|
|
806
|
-
c: ' ',
|
|
807
|
-
e: ' ',
|
|
808
|
-
k: ' ',
|
|
809
|
-
l: ' ',
|
|
810
|
-
p: ' ',
|
|
811
|
-
P: ' '
|
|
812
|
-
};
|
|
867
|
+
var padSpaceChars = new Set('aAbBceklpP');
|
|
813
868
|
function getTimezoneOffset(d, opts) {
|
|
814
869
|
var nOffset = Math.abs(d.getTimezoneOffset());
|
|
815
870
|
var h = Math.floor(nOffset / 60);
|
|
@@ -820,10 +875,10 @@
|
|
|
820
875
|
padStart(m, 2, '0');
|
|
821
876
|
}
|
|
822
877
|
var formatCodes = {
|
|
823
|
-
a: function (d) { return
|
|
824
|
-
A: function (d) { return
|
|
825
|
-
b: function (d) { return
|
|
826
|
-
B: function (d) { return
|
|
878
|
+
a: function (d) { return d.getShortWeekdayName(); },
|
|
879
|
+
A: function (d) { return d.getLongWeekdayName(); },
|
|
880
|
+
b: function (d) { return d.getShortMonthName(); },
|
|
881
|
+
B: function (d) { return d.getLongMonthName(); },
|
|
827
882
|
c: function (d) { return d.toLocaleString(); },
|
|
828
883
|
C: function (d) { return century(d); },
|
|
829
884
|
d: function (d) { return d.getDate(); },
|
|
@@ -855,12 +910,7 @@
|
|
|
855
910
|
y: function (d) { return d.getFullYear().toString().slice(2, 4); },
|
|
856
911
|
Y: function (d) { return d.getFullYear(); },
|
|
857
912
|
z: getTimezoneOffset,
|
|
858
|
-
Z: function (d, opts) {
|
|
859
|
-
if (d.getTimezoneName) {
|
|
860
|
-
return d.getTimezoneName() || getTimezoneOffset(d, opts);
|
|
861
|
-
}
|
|
862
|
-
return (typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().timeZone : '');
|
|
863
|
-
},
|
|
913
|
+
Z: function (d, opts) { return d.getTimeZoneName() || getTimezoneOffset(d, opts); },
|
|
864
914
|
't': function () { return '\t'; },
|
|
865
915
|
'n': function () { return '\n'; },
|
|
866
916
|
'%': function () { return '%'; }
|
|
@@ -898,7 +948,7 @@
|
|
|
898
948
|
finally { if (e_1) throw e_1.error; }
|
|
899
949
|
}
|
|
900
950
|
var ret = String(convert(d, { flags: flags, width: width, modifier: modifier }));
|
|
901
|
-
var padChar =
|
|
951
|
+
var padChar = padSpaceChars.has(conversion) ? ' ' : '0';
|
|
902
952
|
var padWidth = width || padWidths[conversion] || 0;
|
|
903
953
|
if (flags['^'])
|
|
904
954
|
ret = ret.toUpperCase();
|
|
@@ -913,9 +963,26 @@
|
|
|
913
963
|
return padStart(ret, padWidth, padChar);
|
|
914
964
|
}
|
|
915
965
|
|
|
966
|
+
function getDateTimeFormat() {
|
|
967
|
+
return (typeof Intl !== 'undefined' ? Intl.DateTimeFormat : undefined);
|
|
968
|
+
}
|
|
969
|
+
|
|
916
970
|
// one minute in milliseconds
|
|
917
971
|
var OneMinute = 60000;
|
|
918
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Need support both ISO8601 and RFC2822 as in major browsers & NodeJS
|
|
974
|
+
* RFC2822: https://datatracker.ietf.org/doc/html/rfc2822#section-3.3
|
|
975
|
+
*/
|
|
976
|
+
var TIMEZONE_PATTERN = /([zZ]|([+-])(\d{2}):?(\d{2}))$/;
|
|
977
|
+
var monthNames = [
|
|
978
|
+
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
|
|
979
|
+
'September', 'October', 'November', 'December'
|
|
980
|
+
];
|
|
981
|
+
var monthNamesShort = monthNames.map(function (name) { return name.slice(0, 3); });
|
|
982
|
+
var dayNames = [
|
|
983
|
+
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
|
|
984
|
+
];
|
|
985
|
+
var dayNamesShort = dayNames.map(function (name) { return name.slice(0, 3); });
|
|
919
986
|
/**
|
|
920
987
|
* A date implementation with timezone info, just like Ruby date
|
|
921
988
|
*
|
|
@@ -923,61 +990,91 @@
|
|
|
923
990
|
* - create a Date offset by it's timezone difference, avoiding overriding a bunch of methods
|
|
924
991
|
* - rewrite getTimezoneOffset() to trick strftime
|
|
925
992
|
*/
|
|
926
|
-
var
|
|
927
|
-
function
|
|
928
|
-
this.
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
this.
|
|
993
|
+
var LiquidDate = /** @class */ (function () {
|
|
994
|
+
function LiquidDate(init, locale, timezone) {
|
|
995
|
+
this.locale = locale;
|
|
996
|
+
this.DateTimeFormat = getDateTimeFormat();
|
|
997
|
+
this.date = new Date(init);
|
|
998
|
+
this.timezoneFixed = timezone !== undefined;
|
|
999
|
+
if (timezone === undefined) {
|
|
1000
|
+
timezone = this.date.getTimezoneOffset();
|
|
1001
|
+
}
|
|
1002
|
+
this.timezoneOffset = isString(timezone) ? LiquidDate.getTimezoneOffset(timezone, this.date) : timezone;
|
|
932
1003
|
this.timezoneName = isString(timezone) ? timezone : '';
|
|
933
1004
|
var diff = (this.date.getTimezoneOffset() - this.timezoneOffset) * OneMinute;
|
|
934
1005
|
var time = this.date.getTime() + diff;
|
|
935
1006
|
this.displayDate = new Date(time);
|
|
936
1007
|
}
|
|
937
|
-
|
|
1008
|
+
LiquidDate.prototype.getTime = function () {
|
|
938
1009
|
return this.displayDate.getTime();
|
|
939
1010
|
};
|
|
940
|
-
|
|
1011
|
+
LiquidDate.prototype.getMilliseconds = function () {
|
|
941
1012
|
return this.displayDate.getMilliseconds();
|
|
942
1013
|
};
|
|
943
|
-
|
|
1014
|
+
LiquidDate.prototype.getSeconds = function () {
|
|
944
1015
|
return this.displayDate.getSeconds();
|
|
945
1016
|
};
|
|
946
|
-
|
|
1017
|
+
LiquidDate.prototype.getMinutes = function () {
|
|
947
1018
|
return this.displayDate.getMinutes();
|
|
948
1019
|
};
|
|
949
|
-
|
|
1020
|
+
LiquidDate.prototype.getHours = function () {
|
|
950
1021
|
return this.displayDate.getHours();
|
|
951
1022
|
};
|
|
952
|
-
|
|
1023
|
+
LiquidDate.prototype.getDay = function () {
|
|
953
1024
|
return this.displayDate.getDay();
|
|
954
1025
|
};
|
|
955
|
-
|
|
1026
|
+
LiquidDate.prototype.getDate = function () {
|
|
956
1027
|
return this.displayDate.getDate();
|
|
957
1028
|
};
|
|
958
|
-
|
|
1029
|
+
LiquidDate.prototype.getMonth = function () {
|
|
959
1030
|
return this.displayDate.getMonth();
|
|
960
1031
|
};
|
|
961
|
-
|
|
1032
|
+
LiquidDate.prototype.getFullYear = function () {
|
|
962
1033
|
return this.displayDate.getFullYear();
|
|
963
1034
|
};
|
|
964
|
-
|
|
1035
|
+
LiquidDate.prototype.toLocaleString = function (locale, init) {
|
|
965
1036
|
if (init === null || init === void 0 ? void 0 : init.timeZone) {
|
|
966
1037
|
return this.date.toLocaleString(locale, init);
|
|
967
1038
|
}
|
|
968
1039
|
return this.displayDate.toLocaleString(locale, init);
|
|
969
1040
|
};
|
|
970
|
-
|
|
1041
|
+
LiquidDate.prototype.toLocaleTimeString = function (locale) {
|
|
971
1042
|
return this.displayDate.toLocaleTimeString(locale);
|
|
972
1043
|
};
|
|
973
|
-
|
|
1044
|
+
LiquidDate.prototype.toLocaleDateString = function (locale) {
|
|
974
1045
|
return this.displayDate.toLocaleDateString(locale);
|
|
975
1046
|
};
|
|
976
|
-
|
|
1047
|
+
LiquidDate.prototype.getTimezoneOffset = function () {
|
|
977
1048
|
return this.timezoneOffset;
|
|
978
1049
|
};
|
|
979
|
-
|
|
980
|
-
|
|
1050
|
+
LiquidDate.prototype.getTimeZoneName = function () {
|
|
1051
|
+
if (this.timezoneFixed)
|
|
1052
|
+
return this.timezoneName;
|
|
1053
|
+
if (!this.DateTimeFormat)
|
|
1054
|
+
return;
|
|
1055
|
+
return this.DateTimeFormat().resolvedOptions().timeZone;
|
|
1056
|
+
};
|
|
1057
|
+
LiquidDate.prototype.getLongMonthName = function () {
|
|
1058
|
+
var _a;
|
|
1059
|
+
return (_a = this.format({ month: 'long' })) !== null && _a !== void 0 ? _a : monthNames[this.getMonth()];
|
|
1060
|
+
};
|
|
1061
|
+
LiquidDate.prototype.getShortMonthName = function () {
|
|
1062
|
+
var _a;
|
|
1063
|
+
return (_a = this.format({ month: 'short' })) !== null && _a !== void 0 ? _a : monthNamesShort[this.getMonth()];
|
|
1064
|
+
};
|
|
1065
|
+
LiquidDate.prototype.getLongWeekdayName = function () {
|
|
1066
|
+
var _a;
|
|
1067
|
+
return (_a = this.format({ weekday: 'long' })) !== null && _a !== void 0 ? _a : dayNames[this.displayDate.getDay()];
|
|
1068
|
+
};
|
|
1069
|
+
LiquidDate.prototype.getShortWeekdayName = function () {
|
|
1070
|
+
var _a;
|
|
1071
|
+
return (_a = this.format({ weekday: 'short' })) !== null && _a !== void 0 ? _a : dayNamesShort[this.displayDate.getDay()];
|
|
1072
|
+
};
|
|
1073
|
+
LiquidDate.prototype.valid = function () {
|
|
1074
|
+
return !isNaN(this.getTime());
|
|
1075
|
+
};
|
|
1076
|
+
LiquidDate.prototype.format = function (options) {
|
|
1077
|
+
return this.DateTimeFormat && this.DateTimeFormat(this.locale, options).format(this.displayDate);
|
|
981
1078
|
};
|
|
982
1079
|
/**
|
|
983
1080
|
* Create a Date object fixed to it's declared Timezone. Both
|
|
@@ -992,29 +1089,46 @@
|
|
|
992
1089
|
* we create a different Date to trick strftime, it's both simpler and more performant.
|
|
993
1090
|
* Given that a template is expected to be parsed fewer times than rendered.
|
|
994
1091
|
*/
|
|
995
|
-
|
|
996
|
-
var m = dateString.match(
|
|
1092
|
+
LiquidDate.createDateFixedToTimezone = function (dateString, locale) {
|
|
1093
|
+
var m = dateString.match(TIMEZONE_PATTERN);
|
|
997
1094
|
// representing a UTC timestamp
|
|
998
1095
|
if (m && m[1] === 'Z') {
|
|
999
|
-
return new
|
|
1096
|
+
return new LiquidDate(+new Date(dateString), locale, 0);
|
|
1000
1097
|
}
|
|
1001
1098
|
// has a timezone specified
|
|
1002
1099
|
if (m && m[2] && m[3] && m[4]) {
|
|
1003
1100
|
var _a = __read(m, 5), sign = _a[2], hours = _a[3], minutes = _a[4];
|
|
1004
1101
|
var offset = (sign === '+' ? -1 : 1) * (parseInt(hours, 10) * 60 + parseInt(minutes, 10));
|
|
1005
|
-
return new
|
|
1102
|
+
return new LiquidDate(+new Date(dateString), locale, offset);
|
|
1006
1103
|
}
|
|
1007
|
-
return new
|
|
1104
|
+
return new LiquidDate(dateString, locale);
|
|
1008
1105
|
};
|
|
1009
|
-
|
|
1010
|
-
if (date === void 0) { date = new Date(); }
|
|
1106
|
+
LiquidDate.getTimezoneOffset = function (timezoneName, date) {
|
|
1011
1107
|
var localDateString = date.toLocaleString('en-US', { timeZone: timezoneName });
|
|
1012
1108
|
var utcDateString = date.toLocaleString('en-US', { timeZone: 'UTC' });
|
|
1013
1109
|
var localDate = new Date(localDateString);
|
|
1014
1110
|
var utcDate = new Date(utcDateString);
|
|
1015
1111
|
return (+utcDate - +localDate) / (60 * 1000);
|
|
1016
1112
|
};
|
|
1017
|
-
return
|
|
1113
|
+
return LiquidDate;
|
|
1114
|
+
}());
|
|
1115
|
+
|
|
1116
|
+
var Limiter = /** @class */ (function () {
|
|
1117
|
+
function Limiter(resource, limit) {
|
|
1118
|
+
this.base = 0;
|
|
1119
|
+
this.message = "".concat(resource, " limit exceeded");
|
|
1120
|
+
this.limit = limit;
|
|
1121
|
+
}
|
|
1122
|
+
Limiter.prototype.use = function (count) {
|
|
1123
|
+
count = toNumber(count);
|
|
1124
|
+
assert(this.base + count <= this.limit, this.message);
|
|
1125
|
+
this.base += count;
|
|
1126
|
+
};
|
|
1127
|
+
Limiter.prototype.check = function (count) {
|
|
1128
|
+
count = toNumber(count);
|
|
1129
|
+
assert(count <= this.limit, this.message);
|
|
1130
|
+
};
|
|
1131
|
+
return Limiter;
|
|
1018
1132
|
}());
|
|
1019
1133
|
|
|
1020
1134
|
var DelimitedToken = /** @class */ (function (_super) {
|
|
@@ -1123,17 +1237,6 @@
|
|
|
1123
1237
|
_this.content = _this.getText();
|
|
1124
1238
|
return _this;
|
|
1125
1239
|
}
|
|
1126
|
-
IdentifierToken.prototype.isNumber = function (allowSign) {
|
|
1127
|
-
if (allowSign === void 0) { allowSign = false; }
|
|
1128
|
-
var begin = allowSign && TYPES[this.input.charCodeAt(this.begin)] & SIGN
|
|
1129
|
-
? this.begin + 1
|
|
1130
|
-
: this.begin;
|
|
1131
|
-
for (var i = begin; i < this.end; i++) {
|
|
1132
|
-
if (!(TYPES[this.input.charCodeAt(i)] & NUMBER))
|
|
1133
|
-
return false;
|
|
1134
|
-
}
|
|
1135
|
-
return true;
|
|
1136
|
-
};
|
|
1137
1240
|
return IdentifierToken;
|
|
1138
1241
|
}(Token));
|
|
1139
1242
|
|
|
@@ -1324,9 +1427,15 @@
|
|
|
1324
1427
|
_this.name = _this.tokenizer.readTagName();
|
|
1325
1428
|
_this.tokenizer.assert(_this.name, 'illegal liquid tag syntax');
|
|
1326
1429
|
_this.tokenizer.skipBlank();
|
|
1327
|
-
_this.args = _this.tokenizer.remaining();
|
|
1328
1430
|
return _this;
|
|
1329
1431
|
}
|
|
1432
|
+
Object.defineProperty(LiquidTagToken.prototype, "args", {
|
|
1433
|
+
get: function () {
|
|
1434
|
+
return this.tokenizer.input.slice(this.tokenizer.p, this.contentRange[1]);
|
|
1435
|
+
},
|
|
1436
|
+
enumerable: false,
|
|
1437
|
+
configurable: true
|
|
1438
|
+
});
|
|
1330
1439
|
return LiquidTagToken;
|
|
1331
1440
|
}(DelimitedToken));
|
|
1332
1441
|
|
|
@@ -1350,6 +1459,15 @@
|
|
|
1350
1459
|
return FilteredValueToken;
|
|
1351
1460
|
}(Token));
|
|
1352
1461
|
|
|
1462
|
+
var polyfill = {
|
|
1463
|
+
now: function () { return Date.now(); }
|
|
1464
|
+
};
|
|
1465
|
+
function getPerformance() {
|
|
1466
|
+
return (typeof global === 'object' && global.performance) ||
|
|
1467
|
+
(typeof window === 'object' && window.performance) ||
|
|
1468
|
+
polyfill;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1353
1471
|
var SimpleEmitter = /** @class */ (function () {
|
|
1354
1472
|
function SimpleEmitter() {
|
|
1355
1473
|
this.buffer = '';
|
|
@@ -1400,7 +1518,7 @@
|
|
|
1400
1518
|
return emitter.stream;
|
|
1401
1519
|
};
|
|
1402
1520
|
Render.prototype.renderTemplates = function (templates, ctx, emitter) {
|
|
1403
|
-
var templates_1, templates_1_1, tpl, html, e_1, err, e_2_1;
|
|
1521
|
+
var errors, templates_1, templates_1_1, tpl, html, e_1, err, e_2_1;
|
|
1404
1522
|
var e_2, _a;
|
|
1405
1523
|
return __generator(this, function (_b) {
|
|
1406
1524
|
switch (_b.label) {
|
|
@@ -1408,6 +1526,7 @@
|
|
|
1408
1526
|
if (!emitter) {
|
|
1409
1527
|
emitter = ctx.opts.keepOutputType ? new KeepingTypeEmitter() : new SimpleEmitter();
|
|
1410
1528
|
}
|
|
1529
|
+
errors = [];
|
|
1411
1530
|
_b.label = 1;
|
|
1412
1531
|
case 1:
|
|
1413
1532
|
_b.trys.push([1, 8, 9, 10]);
|
|
@@ -1416,6 +1535,7 @@
|
|
|
1416
1535
|
case 2:
|
|
1417
1536
|
if (!!templates_1_1.done) return [3 /*break*/, 7];
|
|
1418
1537
|
tpl = templates_1_1.value;
|
|
1538
|
+
ctx.renderLimit.check(getPerformance().now());
|
|
1419
1539
|
_b.label = 3;
|
|
1420
1540
|
case 3:
|
|
1421
1541
|
_b.trys.push([3, 5, , 6]);
|
|
@@ -1426,13 +1546,17 @@
|
|
|
1426
1546
|
html = _b.sent();
|
|
1427
1547
|
// if not, it'll return an `html`, write to the emitter for it
|
|
1428
1548
|
html && emitter.write(html);
|
|
1429
|
-
if (
|
|
1549
|
+
if (ctx.breakCalled || ctx.continueCalled)
|
|
1430
1550
|
return [3 /*break*/, 7];
|
|
1431
1551
|
return [3 /*break*/, 6];
|
|
1432
1552
|
case 5:
|
|
1433
1553
|
e_1 = _b.sent();
|
|
1434
|
-
err =
|
|
1435
|
-
|
|
1554
|
+
err = LiquidError.is(e_1) ? e_1 : new RenderError(e_1, tpl);
|
|
1555
|
+
if (ctx.opts.catchAllErrors)
|
|
1556
|
+
errors.push(err);
|
|
1557
|
+
else
|
|
1558
|
+
throw err;
|
|
1559
|
+
return [3 /*break*/, 6];
|
|
1436
1560
|
case 6:
|
|
1437
1561
|
templates_1_1 = templates_1.next();
|
|
1438
1562
|
return [3 /*break*/, 2];
|
|
@@ -1447,7 +1571,11 @@
|
|
|
1447
1571
|
}
|
|
1448
1572
|
finally { if (e_2) throw e_2.error; }
|
|
1449
1573
|
return [7 /*endfinally*/];
|
|
1450
|
-
case 10:
|
|
1574
|
+
case 10:
|
|
1575
|
+
if (errors.length) {
|
|
1576
|
+
throw new LiquidErrors(errors);
|
|
1577
|
+
}
|
|
1578
|
+
return [2 /*return*/, emitter.buffer];
|
|
1451
1579
|
}
|
|
1452
1580
|
});
|
|
1453
1581
|
};
|
|
@@ -1607,6 +1735,7 @@
|
|
|
1607
1735
|
return [4 /*yield*/, evalToken(token.rhs, ctx)];
|
|
1608
1736
|
case 2:
|
|
1609
1737
|
high = _a.sent();
|
|
1738
|
+
ctx.memoryLimit.use(high - low + 1);
|
|
1610
1739
|
return [2 /*return*/, range(+low, +high + 1)];
|
|
1611
1740
|
}
|
|
1612
1741
|
});
|
|
@@ -1670,6 +1799,7 @@
|
|
|
1670
1799
|
return !isFalsy(val, ctx);
|
|
1671
1800
|
}
|
|
1672
1801
|
function isFalsy(val, ctx) {
|
|
1802
|
+
val = toValue(val);
|
|
1673
1803
|
if (ctx.opts.jsTruthy) {
|
|
1674
1804
|
return !val;
|
|
1675
1805
|
}
|
|
@@ -1737,6 +1867,9 @@
|
|
|
1737
1867
|
if (lhs.length !== rhs.length)
|
|
1738
1868
|
return false;
|
|
1739
1869
|
return !lhs.some(function (value, i) { return !equals(value, rhs[i]); });
|
|
1870
|
+
}
|
|
1871
|
+
function arrayIncludes(arr, item) {
|
|
1872
|
+
return arr.some(function (value) { return equals(value, item); });
|
|
1740
1873
|
}
|
|
1741
1874
|
|
|
1742
1875
|
var Node = /** @class */ (function () {
|
|
@@ -1941,22 +2074,30 @@
|
|
|
1941
2074
|
''': "'"
|
|
1942
2075
|
};
|
|
1943
2076
|
function escape(str) {
|
|
1944
|
-
|
|
2077
|
+
str = stringify(str);
|
|
2078
|
+
this.context.memoryLimit.use(str.length);
|
|
2079
|
+
return str.replace(/&|<|>|"|'/g, function (m) { return escapeMap[m]; });
|
|
1945
2080
|
}
|
|
1946
2081
|
function xml_escape(str) {
|
|
1947
|
-
return escape(str);
|
|
2082
|
+
return escape.call(this, str);
|
|
1948
2083
|
}
|
|
1949
2084
|
function unescape(str) {
|
|
1950
|
-
|
|
2085
|
+
str = stringify(str);
|
|
2086
|
+
this.context.memoryLimit.use(str.length);
|
|
2087
|
+
return str.replace(/&(amp|lt|gt|#34|#39);/g, function (m) { return unescapeMap[m]; });
|
|
1951
2088
|
}
|
|
1952
2089
|
function escape_once(str) {
|
|
1953
|
-
return escape(unescape(
|
|
2090
|
+
return escape.call(this, unescape.call(this, str));
|
|
1954
2091
|
}
|
|
1955
2092
|
function newline_to_br(v) {
|
|
1956
|
-
|
|
2093
|
+
var str = stringify(v);
|
|
2094
|
+
this.context.memoryLimit.use(str.length);
|
|
2095
|
+
return str.replace(/\r?\n/gm, '<br />\n');
|
|
1957
2096
|
}
|
|
1958
2097
|
function strip_html(v) {
|
|
1959
|
-
|
|
2098
|
+
var str = stringify(v);
|
|
2099
|
+
this.context.memoryLimit.use(str.length);
|
|
2100
|
+
return str.replace(/<script[\s\S]*?<\/script>|<style[\s\S]*?<\/style>|<.*?>|<!--[\s\S]*?-->/g, '');
|
|
1960
2101
|
}
|
|
1961
2102
|
|
|
1962
2103
|
var htmlFilters = /*#__PURE__*/Object.freeze({
|
|
@@ -1968,18 +2109,84 @@
|
|
|
1968
2109
|
strip_html: strip_html
|
|
1969
2110
|
});
|
|
1970
2111
|
|
|
2112
|
+
var MapFS = /** @class */ (function () {
|
|
2113
|
+
function MapFS(mapping) {
|
|
2114
|
+
this.mapping = mapping;
|
|
2115
|
+
this.sep = '/';
|
|
2116
|
+
}
|
|
2117
|
+
MapFS.prototype.exists = function (filepath) {
|
|
2118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2119
|
+
return __generator(this, function (_a) {
|
|
2120
|
+
return [2 /*return*/, this.existsSync(filepath)];
|
|
2121
|
+
});
|
|
2122
|
+
});
|
|
2123
|
+
};
|
|
2124
|
+
MapFS.prototype.existsSync = function (filepath) {
|
|
2125
|
+
return !isNil(this.mapping[filepath]);
|
|
2126
|
+
};
|
|
2127
|
+
MapFS.prototype.readFile = function (filepath) {
|
|
2128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2129
|
+
return __generator(this, function (_a) {
|
|
2130
|
+
return [2 /*return*/, this.readFileSync(filepath)];
|
|
2131
|
+
});
|
|
2132
|
+
});
|
|
2133
|
+
};
|
|
2134
|
+
MapFS.prototype.readFileSync = function (filepath) {
|
|
2135
|
+
var content = this.mapping[filepath];
|
|
2136
|
+
if (isNil(content))
|
|
2137
|
+
throw new Error("ENOENT: ".concat(filepath));
|
|
2138
|
+
return content;
|
|
2139
|
+
};
|
|
2140
|
+
MapFS.prototype.dirname = function (filepath) {
|
|
2141
|
+
var segments = filepath.split(this.sep);
|
|
2142
|
+
segments.pop();
|
|
2143
|
+
return segments.join(this.sep);
|
|
2144
|
+
};
|
|
2145
|
+
MapFS.prototype.resolve = function (dir, file, ext) {
|
|
2146
|
+
var e_1, _a;
|
|
2147
|
+
file += ext;
|
|
2148
|
+
if (dir === '.')
|
|
2149
|
+
return file;
|
|
2150
|
+
var segments = dir.split(/\/+/);
|
|
2151
|
+
try {
|
|
2152
|
+
for (var _b = __values(file.split(this.sep)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2153
|
+
var segment = _c.value;
|
|
2154
|
+
if (segment === '.' || segment === '')
|
|
2155
|
+
continue;
|
|
2156
|
+
else if (segment === '..') {
|
|
2157
|
+
if (segments.length > 1 || segments[0] !== '')
|
|
2158
|
+
segments.pop();
|
|
2159
|
+
}
|
|
2160
|
+
else
|
|
2161
|
+
segments.push(segment);
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2165
|
+
finally {
|
|
2166
|
+
try {
|
|
2167
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2168
|
+
}
|
|
2169
|
+
finally { if (e_1) throw e_1.error; }
|
|
2170
|
+
}
|
|
2171
|
+
return segments.join(this.sep);
|
|
2172
|
+
};
|
|
2173
|
+
return MapFS;
|
|
2174
|
+
}());
|
|
2175
|
+
|
|
1971
2176
|
var defaultOptions = {
|
|
1972
2177
|
root: ['.'],
|
|
1973
2178
|
layouts: ['.'],
|
|
1974
2179
|
partials: ['.'],
|
|
1975
2180
|
relativeReference: true,
|
|
1976
2181
|
jekyllInclude: false,
|
|
2182
|
+
keyValueSeparator: ':',
|
|
1977
2183
|
cache: undefined,
|
|
1978
2184
|
extname: '',
|
|
1979
2185
|
fs: fs,
|
|
1980
2186
|
dynamicPartials: true,
|
|
1981
2187
|
jsTruthy: false,
|
|
1982
2188
|
dateFormat: '%A, %B %-e, %Y at %-l:%M %P %z',
|
|
2189
|
+
locale: '',
|
|
1983
2190
|
trimTagRight: false,
|
|
1984
2191
|
trimTagLeft: false,
|
|
1985
2192
|
trimOutputRight: false,
|
|
@@ -1996,9 +2203,13 @@
|
|
|
1996
2203
|
lenientIf: false,
|
|
1997
2204
|
globals: {},
|
|
1998
2205
|
keepOutputType: false,
|
|
1999
|
-
operators: defaultOperators
|
|
2206
|
+
operators: defaultOperators,
|
|
2207
|
+
memoryLimit: Infinity,
|
|
2208
|
+
parseLimit: Infinity,
|
|
2209
|
+
renderLimit: Infinity
|
|
2000
2210
|
};
|
|
2001
2211
|
function normalize(options) {
|
|
2212
|
+
var _a, _b;
|
|
2002
2213
|
if (options.hasOwnProperty('root')) {
|
|
2003
2214
|
if (!options.hasOwnProperty('partials'))
|
|
2004
2215
|
options.partials = options.root;
|
|
@@ -2024,6 +2235,14 @@
|
|
|
2024
2235
|
options.partials = normalizeDirectoryList(options.partials);
|
|
2025
2236
|
options.layouts = normalizeDirectoryList(options.layouts);
|
|
2026
2237
|
options.outputEscape = options.outputEscape && getOutputEscapeFunction(options.outputEscape);
|
|
2238
|
+
if (!options.locale) {
|
|
2239
|
+
options.locale = (_b = (_a = getDateTimeFormat()) === null || _a === void 0 ? void 0 : _a().resolvedOptions().locale) !== null && _b !== void 0 ? _b : 'en-US';
|
|
2240
|
+
}
|
|
2241
|
+
if (options.templates) {
|
|
2242
|
+
options.fs = new MapFS(options.templates);
|
|
2243
|
+
options.relativeReference = true;
|
|
2244
|
+
options.root = options.partials = options.layouts = '.';
|
|
2245
|
+
}
|
|
2027
2246
|
return options;
|
|
2028
2247
|
}
|
|
2029
2248
|
function getOutputEscapeFunction(nameOrFunction) {
|
|
@@ -2161,9 +2380,7 @@
|
|
|
2161
2380
|
this.skipBlank();
|
|
2162
2381
|
if (this.end())
|
|
2163
2382
|
return null;
|
|
2164
|
-
this.assert(this.
|
|
2165
|
-
this.p++;
|
|
2166
|
-
var begin = this.p;
|
|
2383
|
+
this.assert(this.read() === '|', "expected \"|\" before filter");
|
|
2167
2384
|
var name = this.readIdentifier();
|
|
2168
2385
|
if (!name.size()) {
|
|
2169
2386
|
this.assert(this.end(), "expected filter name");
|
|
@@ -2184,7 +2401,7 @@
|
|
|
2184
2401
|
else {
|
|
2185
2402
|
throw this.error('expected ":" after filter name');
|
|
2186
2403
|
}
|
|
2187
|
-
return new FilterToken(name.getText(), args, this.input, begin, this.p, this.file);
|
|
2404
|
+
return new FilterToken(name.getText(), args, this.input, name.begin, this.p, this.file);
|
|
2188
2405
|
};
|
|
2189
2406
|
Tokenizer.prototype.readFilterArg = function () {
|
|
2190
2407
|
var key = this.readValue();
|
|
@@ -2228,7 +2445,6 @@
|
|
|
2228
2445
|
return new HTMLToken(this.input, begin, this.p, this.file);
|
|
2229
2446
|
};
|
|
2230
2447
|
Tokenizer.prototype.readTagToken = function (options) {
|
|
2231
|
-
if (options === void 0) { options = defaultOptions; }
|
|
2232
2448
|
var _a = this, file = _a.file, input = _a.input;
|
|
2233
2449
|
var begin = this.p;
|
|
2234
2450
|
if (this.readToDelimiter(options.tagDelimiterRight) === -1) {
|
|
@@ -2364,7 +2580,7 @@
|
|
|
2364
2580
|
return;
|
|
2365
2581
|
var value;
|
|
2366
2582
|
this.skipBlank();
|
|
2367
|
-
var sep = jekyllStyle ? '=' : ':';
|
|
2583
|
+
var sep = isString(jekyllStyle) ? jekyllStyle : (jekyllStyle ? '=' : ':');
|
|
2368
2584
|
if (this.peek() === sep) {
|
|
2369
2585
|
++this.p;
|
|
2370
2586
|
value = this.readValue();
|
|
@@ -2381,6 +2597,9 @@
|
|
|
2381
2597
|
Tokenizer.prototype.end = function () {
|
|
2382
2598
|
return this.p >= this.N;
|
|
2383
2599
|
};
|
|
2600
|
+
Tokenizer.prototype.read = function () {
|
|
2601
|
+
return this.input[this.p++];
|
|
2602
|
+
};
|
|
2384
2603
|
Tokenizer.prototype.readTo = function (end) {
|
|
2385
2604
|
while (this.p < this.N) {
|
|
2386
2605
|
++this.p;
|
|
@@ -2624,10 +2843,10 @@
|
|
|
2624
2843
|
* hash['reversed'] === undefined
|
|
2625
2844
|
*/
|
|
2626
2845
|
var Hash = /** @class */ (function () {
|
|
2627
|
-
function Hash(
|
|
2846
|
+
function Hash(input, jekyllStyle) {
|
|
2628
2847
|
var e_1, _a;
|
|
2629
2848
|
this.hash = {};
|
|
2630
|
-
var tokenizer = new Tokenizer(
|
|
2849
|
+
var tokenizer = input instanceof Tokenizer ? input : new Tokenizer(input, {});
|
|
2631
2850
|
try {
|
|
2632
2851
|
for (var _b = __values(tokenizer.readHashes(jekyllStyle)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2633
2852
|
var hash = _c.value;
|
|
@@ -2704,7 +2923,7 @@
|
|
|
2704
2923
|
var hash;
|
|
2705
2924
|
return __generator(this, function (_a) {
|
|
2706
2925
|
switch (_a.label) {
|
|
2707
|
-
case 0: return [4 /*yield*/, new Hash(this.token.args).render(ctx)];
|
|
2926
|
+
case 0: return [4 /*yield*/, new Hash(this.token.args, ctx.opts.keyValueSeparator).render(ctx)];
|
|
2708
2927
|
case 1:
|
|
2709
2928
|
hash = (_a.sent());
|
|
2710
2929
|
return [4 /*yield*/, options.render.call(this, ctx, emitter, hash)];
|
|
@@ -2721,13 +2940,14 @@
|
|
|
2721
2940
|
}
|
|
2722
2941
|
|
|
2723
2942
|
var Filter = /** @class */ (function () {
|
|
2724
|
-
function Filter(
|
|
2725
|
-
this.
|
|
2943
|
+
function Filter(token, options, liquid) {
|
|
2944
|
+
this.token = token;
|
|
2945
|
+
this.name = token.name;
|
|
2726
2946
|
this.handler = isFunction(options)
|
|
2727
2947
|
? options
|
|
2728
2948
|
: (isFunction(options === null || options === void 0 ? void 0 : options.handler) ? options.handler : identify);
|
|
2729
2949
|
this.raw = !isFunction(options) && !!(options === null || options === void 0 ? void 0 : options.raw);
|
|
2730
|
-
this.args = args;
|
|
2950
|
+
this.args = token.args;
|
|
2731
2951
|
this.liquid = liquid;
|
|
2732
2952
|
}
|
|
2733
2953
|
Filter.prototype.render = function (value, context) {
|
|
@@ -2772,7 +2992,7 @@
|
|
|
2772
2992
|
}
|
|
2773
2993
|
finally { if (e_1) throw e_1.error; }
|
|
2774
2994
|
return [7 /*endfinally*/];
|
|
2775
|
-
case 10: return [4 /*yield*/, this.handler.apply({ context: context, liquid: this.liquid }, __spreadArray([value], __read(argv), false))];
|
|
2995
|
+
case 10: return [4 /*yield*/, this.handler.apply({ context: context, token: this.token, liquid: this.liquid }, __spreadArray([value], __read(argv), false))];
|
|
2776
2996
|
case 11: return [2 /*return*/, _j.sent()];
|
|
2777
2997
|
}
|
|
2778
2998
|
});
|
|
@@ -2791,10 +3011,7 @@
|
|
|
2791
3011
|
? new Tokenizer(input, liquid.options.operators).readFilteredValue()
|
|
2792
3012
|
: input;
|
|
2793
3013
|
this.initial = token.initial;
|
|
2794
|
-
this.filters = token.filters.map(function (
|
|
2795
|
-
var name = _a.name, args = _a.args;
|
|
2796
|
-
return new Filter(name, _this.getFilter(liquid, name), args, liquid);
|
|
2797
|
-
});
|
|
3014
|
+
this.filters = token.filters.map(function (token) { return new Filter(token, _this.getFilter(liquid, token.name), liquid); });
|
|
2798
3015
|
}
|
|
2799
3016
|
Value.prototype.value = function (ctx, lenient) {
|
|
2800
3017
|
var val, _a, _b, filter, e_1_1;
|
|
@@ -2855,7 +3072,8 @@
|
|
|
2855
3072
|
var filters = _this.value.filters;
|
|
2856
3073
|
var outputEscape = liquid.options.outputEscape;
|
|
2857
3074
|
if (!((_a = filters[filters.length - 1]) === null || _a === void 0 ? void 0 : _a.raw) && outputEscape) {
|
|
2858
|
-
|
|
3075
|
+
var token_1 = new FilterToken(toString.call(outputEscape), [], '', 0, 0);
|
|
3076
|
+
filters.push(new Filter(token_1, outputEscape, liquid));
|
|
2859
3077
|
}
|
|
2860
3078
|
return _this;
|
|
2861
3079
|
}
|
|
@@ -2871,6 +3089,16 @@
|
|
|
2871
3089
|
}
|
|
2872
3090
|
});
|
|
2873
3091
|
};
|
|
3092
|
+
Output.prototype.arguments = function () {
|
|
3093
|
+
return __generator(this, function (_a) {
|
|
3094
|
+
switch (_a.label) {
|
|
3095
|
+
case 0: return [4 /*yield*/, this.value];
|
|
3096
|
+
case 1:
|
|
3097
|
+
_a.sent();
|
|
3098
|
+
return [2 /*return*/];
|
|
3099
|
+
}
|
|
3100
|
+
});
|
|
3101
|
+
};
|
|
2874
3102
|
return Output;
|
|
2875
3103
|
}(TemplateImpl));
|
|
2876
3104
|
|
|
@@ -2890,87 +3118,759 @@
|
|
|
2890
3118
|
return HTML;
|
|
2891
3119
|
}(TemplateImpl));
|
|
2892
3120
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
3121
|
+
/**
|
|
3122
|
+
* A variable's segments and location, which can be coerced to a string.
|
|
3123
|
+
*/
|
|
3124
|
+
var Variable = /** @class */ (function () {
|
|
3125
|
+
function Variable(segments, location) {
|
|
3126
|
+
this.segments = segments;
|
|
3127
|
+
this.location = location;
|
|
3128
|
+
}
|
|
3129
|
+
Variable.prototype.toString = function () {
|
|
3130
|
+
return segmentsString(this.segments, true);
|
|
3131
|
+
};
|
|
3132
|
+
/** Return this variable's segments as an array, possibly with nested arrays for nested paths. */
|
|
3133
|
+
Variable.prototype.toArray = function () {
|
|
3134
|
+
function _visit() {
|
|
3135
|
+
var _i, segments_1, segments_1_1, segment, e_1_1;
|
|
3136
|
+
var e_1, _a;
|
|
3137
|
+
var segments = [];
|
|
3138
|
+
for (_i = 0; _i < arguments.length; _i++) {
|
|
3139
|
+
segments[_i] = arguments[_i];
|
|
3140
|
+
}
|
|
3141
|
+
return __generator(this, function (_b) {
|
|
3142
|
+
switch (_b.label) {
|
|
3143
|
+
case 0:
|
|
3144
|
+
_b.trys.push([0, 7, 8, 9]);
|
|
3145
|
+
segments_1 = __values(segments), segments_1_1 = segments_1.next();
|
|
3146
|
+
_b.label = 1;
|
|
3147
|
+
case 1:
|
|
3148
|
+
if (!!segments_1_1.done) return [3 /*break*/, 6];
|
|
3149
|
+
segment = segments_1_1.value;
|
|
3150
|
+
if (!(segment instanceof Variable)) return [3 /*break*/, 3];
|
|
3151
|
+
return [4 /*yield*/, Array.from(_visit.apply(void 0, __spreadArray([], __read(segment.segments), false)))];
|
|
3152
|
+
case 2:
|
|
3153
|
+
_b.sent();
|
|
3154
|
+
return [3 /*break*/, 5];
|
|
3155
|
+
case 3: return [4 /*yield*/, segment];
|
|
3156
|
+
case 4:
|
|
3157
|
+
_b.sent();
|
|
3158
|
+
_b.label = 5;
|
|
3159
|
+
case 5:
|
|
3160
|
+
segments_1_1 = segments_1.next();
|
|
3161
|
+
return [3 /*break*/, 1];
|
|
3162
|
+
case 6: return [3 /*break*/, 9];
|
|
3163
|
+
case 7:
|
|
3164
|
+
e_1_1 = _b.sent();
|
|
3165
|
+
e_1 = { error: e_1_1 };
|
|
3166
|
+
return [3 /*break*/, 9];
|
|
3167
|
+
case 8:
|
|
3168
|
+
try {
|
|
3169
|
+
if (segments_1_1 && !segments_1_1.done && (_a = segments_1.return)) _a.call(segments_1);
|
|
3170
|
+
}
|
|
3171
|
+
finally { if (e_1) throw e_1.error; }
|
|
3172
|
+
return [7 /*endfinally*/];
|
|
3173
|
+
case 9: return [2 /*return*/];
|
|
3174
|
+
}
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
return Array.from(_visit.apply(void 0, __spreadArray([], __read(this.segments), false)));
|
|
3178
|
+
};
|
|
3179
|
+
return Variable;
|
|
3180
|
+
}());
|
|
3181
|
+
/**
|
|
3182
|
+
* Group variables by the string representation of their root segment.
|
|
3183
|
+
*/
|
|
3184
|
+
var VariableMap = /** @class */ (function () {
|
|
3185
|
+
function VariableMap() {
|
|
3186
|
+
this.map = new Map();
|
|
3187
|
+
}
|
|
3188
|
+
VariableMap.prototype.get = function (key) {
|
|
3189
|
+
var k = segmentsString([key.segments[0]]);
|
|
3190
|
+
if (!this.map.has(k)) {
|
|
3191
|
+
this.map.set(k, []);
|
|
3192
|
+
}
|
|
3193
|
+
return this.map.get(k);
|
|
3194
|
+
};
|
|
3195
|
+
VariableMap.prototype.has = function (key) {
|
|
3196
|
+
return this.map.has(segmentsString([key.segments[0]]));
|
|
3197
|
+
};
|
|
3198
|
+
VariableMap.prototype.push = function (variable) {
|
|
3199
|
+
this.get(variable).push(variable);
|
|
3200
|
+
};
|
|
3201
|
+
VariableMap.prototype.asObject = function () {
|
|
3202
|
+
return Object.fromEntries(this.map);
|
|
3203
|
+
};
|
|
3204
|
+
return VariableMap;
|
|
3205
|
+
}());
|
|
3206
|
+
var defaultStaticAnalysisOptions = {
|
|
3207
|
+
partials: true
|
|
3208
|
+
};
|
|
3209
|
+
function _analyze(templates, partials, sync) {
|
|
3210
|
+
function updateVariables(variable, scope) {
|
|
3211
|
+
var e_3, _a;
|
|
3212
|
+
variables.push(variable);
|
|
3213
|
+
var aliased = scope.alias(variable);
|
|
3214
|
+
if (aliased !== undefined) {
|
|
3215
|
+
var root = aliased.segments[0];
|
|
3216
|
+
// TODO: What if a a template renders a rendered template? Do we need scope.parent?
|
|
3217
|
+
if (isString(root) && !rootScope.has(root)) {
|
|
3218
|
+
globals.push(aliased);
|
|
3219
|
+
}
|
|
2907
3220
|
}
|
|
2908
3221
|
else {
|
|
2909
|
-
|
|
3222
|
+
var root = variable.segments[0];
|
|
3223
|
+
if (isString(root) && !scope.has(root)) {
|
|
3224
|
+
globals.push(variable);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
try {
|
|
3228
|
+
// Recurse for nested Variables
|
|
3229
|
+
for (var _b = __values(variable.segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3230
|
+
var segment = _c.value;
|
|
3231
|
+
if (segment instanceof Variable) {
|
|
3232
|
+
updateVariables(segment, scope);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3237
|
+
finally {
|
|
3238
|
+
try {
|
|
3239
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3240
|
+
}
|
|
3241
|
+
finally { if (e_3) throw e_3.error; }
|
|
2910
3242
|
}
|
|
2911
|
-
this.contains = this.options.fs.contains || (function () { return true; });
|
|
2912
3243
|
}
|
|
2913
|
-
|
|
2914
|
-
var
|
|
2915
|
-
var
|
|
2916
|
-
return __generator(this, function (
|
|
2917
|
-
switch (
|
|
3244
|
+
function visit(template, scope) {
|
|
3245
|
+
var _a, _b, arg, _c, _d, variable, _e, _f, ident, _g, row, col, partial, _h, _j, child, e_4_1, partialScopeNames, partialScope, _k, _l, name_1, _m, alias, argument, variables_1, _o, _p, child, e_5_1, _q, _r, child, e_6_1;
|
|
3246
|
+
var e_7, _s, e_8, _t, e_9, _u, e_4, _v, e_10, _w, e_5, _x, e_6, _y;
|
|
3247
|
+
return __generator(this, function (_z) {
|
|
3248
|
+
switch (_z.label) {
|
|
2918
3249
|
case 0:
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
3250
|
+
if (template.arguments) {
|
|
3251
|
+
try {
|
|
3252
|
+
for (_a = __values(template.arguments()), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3253
|
+
arg = _b.value;
|
|
3254
|
+
try {
|
|
3255
|
+
for (_c = (e_8 = void 0, __values(extractVariables(arg))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3256
|
+
variable = _d.value;
|
|
3257
|
+
updateVariables(variable, scope);
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
3261
|
+
finally {
|
|
3262
|
+
try {
|
|
3263
|
+
if (_d && !_d.done && (_t = _c.return)) _t.call(_c);
|
|
3264
|
+
}
|
|
3265
|
+
finally { if (e_8) throw e_8.error; }
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
3270
|
+
finally {
|
|
3271
|
+
try {
|
|
3272
|
+
if (_b && !_b.done && (_s = _a.return)) _s.call(_a);
|
|
3273
|
+
}
|
|
3274
|
+
finally { if (e_7) throw e_7.error; }
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
if (template.localScope) {
|
|
3278
|
+
try {
|
|
3279
|
+
for (_e = __values(template.localScope()), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
3280
|
+
ident = _f.value;
|
|
3281
|
+
scope.add(ident.content);
|
|
3282
|
+
scope.deleteAlias(ident.content);
|
|
3283
|
+
_g = __read(ident.getPosition(), 2), row = _g[0], col = _g[1];
|
|
3284
|
+
locals.push(new Variable([ident.content], { row: row, col: col, file: ident.file }));
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
3288
|
+
finally {
|
|
3289
|
+
try {
|
|
3290
|
+
if (_f && !_f.done && (_u = _e.return)) _u.call(_e);
|
|
3291
|
+
}
|
|
3292
|
+
finally { if (e_9) throw e_9.error; }
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
if (!template.children) return [3 /*break*/, 30];
|
|
3296
|
+
if (!template.partialScope) return [3 /*break*/, 20];
|
|
3297
|
+
partial = template.partialScope();
|
|
3298
|
+
if (!(partial === undefined)) return [3 /*break*/, 10];
|
|
3299
|
+
_z.label = 1;
|
|
2922
3300
|
case 1:
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
_e.label = 2;
|
|
3301
|
+
_z.trys.push([1, 7, 8, 9]);
|
|
3302
|
+
return [4 /*yield*/, template.children(partials, sync)];
|
|
2926
3303
|
case 2:
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3304
|
+
_h = __values.apply(void 0, [(_z.sent())]), _j = _h.next();
|
|
3305
|
+
_z.label = 3;
|
|
3306
|
+
case 3:
|
|
3307
|
+
if (!!_j.done) return [3 /*break*/, 6];
|
|
3308
|
+
child = _j.value;
|
|
3309
|
+
return [4 /*yield*/, visit(child, scope)];
|
|
2933
3310
|
case 4:
|
|
2934
|
-
|
|
2935
|
-
|
|
3311
|
+
_z.sent();
|
|
3312
|
+
_z.label = 5;
|
|
2936
3313
|
case 5:
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
case
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
3314
|
+
_j = _h.next();
|
|
3315
|
+
return [3 /*break*/, 3];
|
|
3316
|
+
case 6: return [3 /*break*/, 9];
|
|
3317
|
+
case 7:
|
|
3318
|
+
e_4_1 = _z.sent();
|
|
3319
|
+
e_4 = { error: e_4_1 };
|
|
3320
|
+
return [3 /*break*/, 9];
|
|
2944
3321
|
case 8:
|
|
2945
|
-
e_1_1 = _e.sent();
|
|
2946
|
-
e_1 = { error: e_1_1 };
|
|
2947
|
-
return [3 /*break*/, 10];
|
|
2948
|
-
case 9:
|
|
2949
3322
|
try {
|
|
2950
|
-
if (
|
|
3323
|
+
if (_j && !_j.done && (_v = _h.return)) _v.call(_h);
|
|
2951
3324
|
}
|
|
2952
|
-
finally { if (
|
|
3325
|
+
finally { if (e_4) throw e_4.error; }
|
|
2953
3326
|
return [7 /*endfinally*/];
|
|
2954
|
-
case
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
3327
|
+
case 9: return [2 /*return*/];
|
|
3328
|
+
case 10:
|
|
3329
|
+
if (seen.has(partial.name))
|
|
3330
|
+
return [2 /*return*/];
|
|
3331
|
+
partialScopeNames = new Set();
|
|
3332
|
+
partialScope = partial.isolated
|
|
3333
|
+
? new DummyScope(partialScopeNames)
|
|
3334
|
+
: scope.push(partialScopeNames);
|
|
3335
|
+
try {
|
|
3336
|
+
for (_k = __values(partial.scope), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
3337
|
+
name_1 = _l.value;
|
|
3338
|
+
if (isString(name_1)) {
|
|
3339
|
+
partialScopeNames.add(name_1);
|
|
3340
|
+
}
|
|
3341
|
+
else {
|
|
3342
|
+
_m = __read(name_1, 2), alias = _m[0], argument = _m[1];
|
|
3343
|
+
partialScopeNames.add(alias);
|
|
3344
|
+
variables_1 = Array.from(extractVariables(argument));
|
|
3345
|
+
if (variables_1.length) {
|
|
3346
|
+
partialScope.setAlias(alias, variables_1[0].segments);
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
3352
|
+
finally {
|
|
3353
|
+
try {
|
|
3354
|
+
if (_l && !_l.done && (_w = _k.return)) _w.call(_k);
|
|
3355
|
+
}
|
|
3356
|
+
finally { if (e_10) throw e_10.error; }
|
|
3357
|
+
}
|
|
3358
|
+
_z.label = 11;
|
|
3359
|
+
case 11:
|
|
3360
|
+
_z.trys.push([11, 17, 18, 19]);
|
|
3361
|
+
return [4 /*yield*/, template.children(partials, sync)];
|
|
3362
|
+
case 12:
|
|
3363
|
+
_o = __values.apply(void 0, [(_z.sent())]), _p = _o.next();
|
|
3364
|
+
_z.label = 13;
|
|
3365
|
+
case 13:
|
|
3366
|
+
if (!!_p.done) return [3 /*break*/, 16];
|
|
3367
|
+
child = _p.value;
|
|
3368
|
+
return [4 /*yield*/, visit(child, partialScope)];
|
|
3369
|
+
case 14:
|
|
3370
|
+
_z.sent();
|
|
3371
|
+
seen.add(partial.name);
|
|
3372
|
+
_z.label = 15;
|
|
3373
|
+
case 15:
|
|
3374
|
+
_p = _o.next();
|
|
3375
|
+
return [3 /*break*/, 13];
|
|
3376
|
+
case 16: return [3 /*break*/, 19];
|
|
3377
|
+
case 17:
|
|
3378
|
+
e_5_1 = _z.sent();
|
|
3379
|
+
e_5 = { error: e_5_1 };
|
|
3380
|
+
return [3 /*break*/, 19];
|
|
3381
|
+
case 18:
|
|
3382
|
+
try {
|
|
3383
|
+
if (_p && !_p.done && (_x = _o.return)) _x.call(_o);
|
|
3384
|
+
}
|
|
3385
|
+
finally { if (e_5) throw e_5.error; }
|
|
3386
|
+
return [7 /*endfinally*/];
|
|
3387
|
+
case 19:
|
|
3388
|
+
partialScope.pop();
|
|
3389
|
+
return [3 /*break*/, 30];
|
|
3390
|
+
case 20:
|
|
3391
|
+
if (template.blockScope) {
|
|
3392
|
+
scope.push(new Set(template.blockScope()));
|
|
3393
|
+
}
|
|
3394
|
+
_z.label = 21;
|
|
3395
|
+
case 21:
|
|
3396
|
+
_z.trys.push([21, 27, 28, 29]);
|
|
3397
|
+
return [4 /*yield*/, template.children(partials, sync)];
|
|
3398
|
+
case 22:
|
|
3399
|
+
_q = __values.apply(void 0, [(_z.sent())]), _r = _q.next();
|
|
3400
|
+
_z.label = 23;
|
|
3401
|
+
case 23:
|
|
3402
|
+
if (!!_r.done) return [3 /*break*/, 26];
|
|
3403
|
+
child = _r.value;
|
|
3404
|
+
return [4 /*yield*/, visit(child, scope)];
|
|
3405
|
+
case 24:
|
|
3406
|
+
_z.sent();
|
|
3407
|
+
_z.label = 25;
|
|
3408
|
+
case 25:
|
|
3409
|
+
_r = _q.next();
|
|
3410
|
+
return [3 /*break*/, 23];
|
|
3411
|
+
case 26: return [3 /*break*/, 29];
|
|
3412
|
+
case 27:
|
|
3413
|
+
e_6_1 = _z.sent();
|
|
3414
|
+
e_6 = { error: e_6_1 };
|
|
3415
|
+
return [3 /*break*/, 29];
|
|
3416
|
+
case 28:
|
|
3417
|
+
try {
|
|
3418
|
+
if (_r && !_r.done && (_y = _q.return)) _y.call(_q);
|
|
3419
|
+
}
|
|
3420
|
+
finally { if (e_6) throw e_6.error; }
|
|
3421
|
+
return [7 /*endfinally*/];
|
|
3422
|
+
case 29:
|
|
3423
|
+
if (template.blockScope) {
|
|
3424
|
+
scope.pop();
|
|
3425
|
+
}
|
|
3426
|
+
_z.label = 30;
|
|
3427
|
+
case 30: return [2 /*return*/];
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
var variables, globals, locals, rootScope, seen, templates_1, templates_1_1, template, e_2_1;
|
|
3432
|
+
var e_2, _a;
|
|
3433
|
+
return __generator(this, function (_b) {
|
|
3434
|
+
switch (_b.label) {
|
|
3435
|
+
case 0:
|
|
3436
|
+
variables = new VariableMap();
|
|
3437
|
+
globals = new VariableMap();
|
|
3438
|
+
locals = new VariableMap();
|
|
3439
|
+
rootScope = new DummyScope(new Set());
|
|
3440
|
+
seen = new Set();
|
|
3441
|
+
_b.label = 1;
|
|
3442
|
+
case 1:
|
|
3443
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
3444
|
+
templates_1 = __values(templates), templates_1_1 = templates_1.next();
|
|
3445
|
+
_b.label = 2;
|
|
3446
|
+
case 2:
|
|
3447
|
+
if (!!templates_1_1.done) return [3 /*break*/, 5];
|
|
3448
|
+
template = templates_1_1.value;
|
|
3449
|
+
return [4 /*yield*/, visit(template, rootScope)];
|
|
3450
|
+
case 3:
|
|
3451
|
+
_b.sent();
|
|
3452
|
+
_b.label = 4;
|
|
3453
|
+
case 4:
|
|
3454
|
+
templates_1_1 = templates_1.next();
|
|
3455
|
+
return [3 /*break*/, 2];
|
|
3456
|
+
case 5: return [3 /*break*/, 8];
|
|
3457
|
+
case 6:
|
|
3458
|
+
e_2_1 = _b.sent();
|
|
3459
|
+
e_2 = { error: e_2_1 };
|
|
3460
|
+
return [3 /*break*/, 8];
|
|
3461
|
+
case 7:
|
|
3462
|
+
try {
|
|
3463
|
+
if (templates_1_1 && !templates_1_1.done && (_a = templates_1.return)) _a.call(templates_1);
|
|
3464
|
+
}
|
|
3465
|
+
finally { if (e_2) throw e_2.error; }
|
|
3466
|
+
return [7 /*endfinally*/];
|
|
3467
|
+
case 8: return [2 /*return*/, {
|
|
3468
|
+
variables: variables.asObject(),
|
|
3469
|
+
globals: globals.asObject(),
|
|
3470
|
+
locals: locals.asObject()
|
|
3471
|
+
}];
|
|
3472
|
+
}
|
|
3473
|
+
});
|
|
3474
|
+
}
|
|
3475
|
+
/**
|
|
3476
|
+
* Statically analyze a template and report variable usage.
|
|
3477
|
+
*/
|
|
3478
|
+
function analyze(template, options) {
|
|
3479
|
+
if (options === void 0) { options = {}; }
|
|
3480
|
+
var opts = __assign(__assign({}, defaultStaticAnalysisOptions), options);
|
|
3481
|
+
return toPromise(_analyze(template, opts.partials, false));
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Statically analyze a template and report variable usage.
|
|
3485
|
+
*/
|
|
3486
|
+
function analyzeSync(template, options) {
|
|
3487
|
+
if (options === void 0) { options = {}; }
|
|
3488
|
+
var opts = __assign(__assign({}, defaultStaticAnalysisOptions), options);
|
|
3489
|
+
return toValueSync(_analyze(template, opts.partials, true));
|
|
3490
|
+
}
|
|
3491
|
+
/**
|
|
3492
|
+
* A stack to manage scopes while traversing templates during static analysis.
|
|
3493
|
+
*/
|
|
3494
|
+
var DummyScope = /** @class */ (function () {
|
|
3495
|
+
function DummyScope(globals) {
|
|
3496
|
+
this.stack = [{ names: globals, aliases: new Map() }];
|
|
3497
|
+
}
|
|
3498
|
+
/** Return true if `name` is in scope. */
|
|
3499
|
+
DummyScope.prototype.has = function (name) {
|
|
3500
|
+
var e_11, _a;
|
|
3501
|
+
try {
|
|
3502
|
+
for (var _b = __values(this.stack), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3503
|
+
var scope = _c.value;
|
|
3504
|
+
if (scope.names.has(name)) {
|
|
3505
|
+
return true;
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
3510
|
+
finally {
|
|
3511
|
+
try {
|
|
3512
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3513
|
+
}
|
|
3514
|
+
finally { if (e_11) throw e_11.error; }
|
|
3515
|
+
}
|
|
3516
|
+
return false;
|
|
3517
|
+
};
|
|
3518
|
+
DummyScope.prototype.push = function (scope) {
|
|
3519
|
+
this.stack.push({ names: scope, aliases: new Map() });
|
|
3520
|
+
return this;
|
|
3521
|
+
};
|
|
3522
|
+
DummyScope.prototype.pop = function () {
|
|
3523
|
+
var _a;
|
|
3524
|
+
return (_a = this.stack.pop()) === null || _a === void 0 ? void 0 : _a.names;
|
|
3525
|
+
};
|
|
3526
|
+
// Add a name to the template scope.
|
|
3527
|
+
DummyScope.prototype.add = function (name) {
|
|
3528
|
+
this.stack[0].names.add(name);
|
|
3529
|
+
};
|
|
3530
|
+
/** Return the variable that `variable` aliases, or `variable` if it doesn't alias anything. */
|
|
3531
|
+
DummyScope.prototype.alias = function (variable) {
|
|
3532
|
+
var root = variable.segments[0];
|
|
3533
|
+
if (!isString(root))
|
|
3534
|
+
return undefined;
|
|
3535
|
+
var alias = this.getAlias(root);
|
|
3536
|
+
if (alias === undefined)
|
|
3537
|
+
return undefined;
|
|
3538
|
+
return new Variable(__spreadArray(__spreadArray([], __read(alias), false), __read(variable.segments.slice(1)), false), variable.location);
|
|
3539
|
+
};
|
|
3540
|
+
// TODO: `from` could be a path with multiple segments, like `include.x`.
|
|
3541
|
+
DummyScope.prototype.setAlias = function (from, to) {
|
|
3542
|
+
this.stack[this.stack.length - 1].aliases.set(from, to);
|
|
3543
|
+
};
|
|
3544
|
+
DummyScope.prototype.deleteAlias = function (name) {
|
|
3545
|
+
this.stack[this.stack.length - 1].aliases.delete(name);
|
|
3546
|
+
};
|
|
3547
|
+
DummyScope.prototype.getAlias = function (name) {
|
|
3548
|
+
var e_12, _a;
|
|
3549
|
+
try {
|
|
3550
|
+
for (var _b = __values(this.stack), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3551
|
+
var scope = _c.value;
|
|
3552
|
+
if (scope.aliases.has(name)) {
|
|
3553
|
+
return scope.aliases.get(name);
|
|
3554
|
+
}
|
|
3555
|
+
// If a scope has defined `name`, then it masks aliases in parent scopes.
|
|
3556
|
+
if (scope.names.has(name)) {
|
|
3557
|
+
return undefined;
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
3562
|
+
finally {
|
|
3563
|
+
try {
|
|
3564
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3565
|
+
}
|
|
3566
|
+
finally { if (e_12) throw e_12.error; }
|
|
3567
|
+
}
|
|
3568
|
+
return undefined;
|
|
3569
|
+
};
|
|
3570
|
+
return DummyScope;
|
|
3571
|
+
}());
|
|
3572
|
+
function extractVariables(value) {
|
|
3573
|
+
return __generator(this, function (_a) {
|
|
3574
|
+
switch (_a.label) {
|
|
3575
|
+
case 0:
|
|
3576
|
+
if (!isValueToken(value)) return [3 /*break*/, 2];
|
|
3577
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(value))];
|
|
3578
|
+
case 1:
|
|
3579
|
+
_a.sent();
|
|
3580
|
+
return [3 /*break*/, 4];
|
|
3581
|
+
case 2:
|
|
3582
|
+
if (!(value instanceof Value)) return [3 /*break*/, 4];
|
|
3583
|
+
return [5 /*yield**/, __values(extractFilteredValueVariables(value))];
|
|
3584
|
+
case 3:
|
|
3585
|
+
_a.sent();
|
|
3586
|
+
_a.label = 4;
|
|
3587
|
+
case 4: return [2 /*return*/];
|
|
3588
|
+
}
|
|
3589
|
+
});
|
|
3590
|
+
}
|
|
3591
|
+
function extractFilteredValueVariables(value) {
|
|
3592
|
+
var _a, _b, token, e_13_1, _c, _d, filter, _e, _f, arg, e_14_1, e_15_1;
|
|
3593
|
+
var e_13, _g, e_15, _h, e_14, _j;
|
|
3594
|
+
return __generator(this, function (_k) {
|
|
3595
|
+
switch (_k.label) {
|
|
3596
|
+
case 0:
|
|
3597
|
+
_k.trys.push([0, 5, 6, 7]);
|
|
3598
|
+
_a = __values(value.initial.postfix), _b = _a.next();
|
|
3599
|
+
_k.label = 1;
|
|
3600
|
+
case 1:
|
|
3601
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
3602
|
+
token = _b.value;
|
|
3603
|
+
if (!isValueToken(token)) return [3 /*break*/, 3];
|
|
3604
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(token))];
|
|
3605
|
+
case 2:
|
|
3606
|
+
_k.sent();
|
|
3607
|
+
_k.label = 3;
|
|
3608
|
+
case 3:
|
|
3609
|
+
_b = _a.next();
|
|
3610
|
+
return [3 /*break*/, 1];
|
|
3611
|
+
case 4: return [3 /*break*/, 7];
|
|
3612
|
+
case 5:
|
|
3613
|
+
e_13_1 = _k.sent();
|
|
3614
|
+
e_13 = { error: e_13_1 };
|
|
3615
|
+
return [3 /*break*/, 7];
|
|
3616
|
+
case 6:
|
|
3617
|
+
try {
|
|
3618
|
+
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
3619
|
+
}
|
|
3620
|
+
finally { if (e_13) throw e_13.error; }
|
|
3621
|
+
return [7 /*endfinally*/];
|
|
3622
|
+
case 7:
|
|
3623
|
+
_k.trys.push([7, 20, 21, 22]);
|
|
3624
|
+
_c = __values(value.filters), _d = _c.next();
|
|
3625
|
+
_k.label = 8;
|
|
3626
|
+
case 8:
|
|
3627
|
+
if (!!_d.done) return [3 /*break*/, 19];
|
|
3628
|
+
filter = _d.value;
|
|
3629
|
+
_k.label = 9;
|
|
3630
|
+
case 9:
|
|
3631
|
+
_k.trys.push([9, 16, 17, 18]);
|
|
3632
|
+
_e = (e_14 = void 0, __values(filter.args)), _f = _e.next();
|
|
3633
|
+
_k.label = 10;
|
|
3634
|
+
case 10:
|
|
3635
|
+
if (!!_f.done) return [3 /*break*/, 15];
|
|
3636
|
+
arg = _f.value;
|
|
3637
|
+
if (!(isKeyValuePair(arg) && arg[1])) return [3 /*break*/, 12];
|
|
3638
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(arg[1]))];
|
|
3639
|
+
case 11:
|
|
3640
|
+
_k.sent();
|
|
3641
|
+
return [3 /*break*/, 14];
|
|
3642
|
+
case 12:
|
|
3643
|
+
if (!isValueToken(arg)) return [3 /*break*/, 14];
|
|
3644
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(arg))];
|
|
3645
|
+
case 13:
|
|
3646
|
+
_k.sent();
|
|
3647
|
+
_k.label = 14;
|
|
3648
|
+
case 14:
|
|
3649
|
+
_f = _e.next();
|
|
3650
|
+
return [3 /*break*/, 10];
|
|
3651
|
+
case 15: return [3 /*break*/, 18];
|
|
3652
|
+
case 16:
|
|
3653
|
+
e_14_1 = _k.sent();
|
|
3654
|
+
e_14 = { error: e_14_1 };
|
|
3655
|
+
return [3 /*break*/, 18];
|
|
3656
|
+
case 17:
|
|
3657
|
+
try {
|
|
3658
|
+
if (_f && !_f.done && (_j = _e.return)) _j.call(_e);
|
|
3659
|
+
}
|
|
3660
|
+
finally { if (e_14) throw e_14.error; }
|
|
3661
|
+
return [7 /*endfinally*/];
|
|
3662
|
+
case 18:
|
|
3663
|
+
_d = _c.next();
|
|
3664
|
+
return [3 /*break*/, 8];
|
|
3665
|
+
case 19: return [3 /*break*/, 22];
|
|
3666
|
+
case 20:
|
|
3667
|
+
e_15_1 = _k.sent();
|
|
3668
|
+
e_15 = { error: e_15_1 };
|
|
3669
|
+
return [3 /*break*/, 22];
|
|
3670
|
+
case 21:
|
|
3671
|
+
try {
|
|
3672
|
+
if (_d && !_d.done && (_h = _c.return)) _h.call(_c);
|
|
3673
|
+
}
|
|
3674
|
+
finally { if (e_15) throw e_15.error; }
|
|
3675
|
+
return [7 /*endfinally*/];
|
|
3676
|
+
case 22: return [2 /*return*/];
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
function extractValueTokenVariables(token) {
|
|
3681
|
+
return __generator(this, function (_a) {
|
|
3682
|
+
switch (_a.label) {
|
|
3683
|
+
case 0:
|
|
3684
|
+
if (!isRangeToken(token)) return [3 /*break*/, 3];
|
|
3685
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(token.lhs))];
|
|
3686
|
+
case 1:
|
|
3687
|
+
_a.sent();
|
|
3688
|
+
return [5 /*yield**/, __values(extractValueTokenVariables(token.rhs))];
|
|
3689
|
+
case 2:
|
|
3690
|
+
_a.sent();
|
|
3691
|
+
return [3 /*break*/, 5];
|
|
3692
|
+
case 3:
|
|
3693
|
+
if (!isPropertyAccessToken(token)) return [3 /*break*/, 5];
|
|
3694
|
+
return [4 /*yield*/, extractPropertyAccessVariable(token)];
|
|
3695
|
+
case 4:
|
|
3696
|
+
_a.sent();
|
|
3697
|
+
_a.label = 5;
|
|
3698
|
+
case 5: return [2 /*return*/];
|
|
3699
|
+
}
|
|
3700
|
+
});
|
|
3701
|
+
}
|
|
3702
|
+
function extractPropertyAccessVariable(token) {
|
|
3703
|
+
var e_16, _a;
|
|
3704
|
+
var segments = [];
|
|
3705
|
+
// token is not guaranteed to have `file` set. We'll try to get it from a prop if not.
|
|
3706
|
+
var file = token.file;
|
|
3707
|
+
// Here we're flattening the first segment of a path if it is a nested path.
|
|
3708
|
+
var root = token.props[0];
|
|
3709
|
+
file = file || root.file;
|
|
3710
|
+
if (isQuotedToken(root) || isNumberToken(root) || isWordToken(root)) {
|
|
3711
|
+
segments.push(root.content);
|
|
3712
|
+
}
|
|
3713
|
+
else if (isPropertyAccessToken(root)) {
|
|
3714
|
+
// Flatten paths that start with a nested path.
|
|
3715
|
+
segments.push.apply(segments, __spreadArray([], __read(extractPropertyAccessVariable(root).segments), false));
|
|
3716
|
+
}
|
|
3717
|
+
try {
|
|
3718
|
+
for (var _b = __values(token.props.slice(1)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3719
|
+
var prop = _c.value;
|
|
3720
|
+
file = file || prop.file;
|
|
3721
|
+
if (isQuotedToken(prop) || isNumberToken(prop) || isWordToken(prop)) {
|
|
3722
|
+
segments.push(prop.content);
|
|
3723
|
+
}
|
|
3724
|
+
else if (isPropertyAccessToken(prop)) {
|
|
3725
|
+
segments.push(extractPropertyAccessVariable(prop));
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
3730
|
+
finally {
|
|
3731
|
+
try {
|
|
3732
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3733
|
+
}
|
|
3734
|
+
finally { if (e_16) throw e_16.error; }
|
|
3735
|
+
}
|
|
3736
|
+
var _d = __read(token.getPosition(), 2), row = _d[0], col = _d[1];
|
|
3737
|
+
return new Variable(segments, {
|
|
3738
|
+
row: row,
|
|
3739
|
+
col: col,
|
|
3740
|
+
file: file
|
|
3741
|
+
});
|
|
3742
|
+
}
|
|
3743
|
+
// This is used to detect segments that can be represented with dot notation
|
|
3744
|
+
// when creating a string representation of VariableSegments.
|
|
3745
|
+
var RE_PROPERTY = /^[\u0080-\uFFFFa-zA-Z_][\u0080-\uFFFFa-zA-Z0-9_-]*$/;
|
|
3746
|
+
/**
|
|
3747
|
+
* Return a string representation of segments using dot notation where possible.
|
|
3748
|
+
* @param segments - The property names and array indices that make up a path to a variable.
|
|
3749
|
+
* @param bracketedRoot - If false (the default), don't surround the root segment with square brackets.
|
|
3750
|
+
*/
|
|
3751
|
+
function segmentsString(segments, bracketedRoot) {
|
|
3752
|
+
var e_17, _a;
|
|
3753
|
+
if (bracketedRoot === void 0) { bracketedRoot = false; }
|
|
3754
|
+
var buf = [];
|
|
3755
|
+
var root = segments[0];
|
|
3756
|
+
if (isString(root)) {
|
|
3757
|
+
if (!bracketedRoot || root.match(RE_PROPERTY)) {
|
|
3758
|
+
buf.push("".concat(root));
|
|
3759
|
+
}
|
|
3760
|
+
else {
|
|
3761
|
+
buf.push("['".concat(root, "']"));
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
try {
|
|
3765
|
+
for (var _b = __values(segments.slice(1)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3766
|
+
var segment = _c.value;
|
|
3767
|
+
if (segment instanceof Variable) {
|
|
3768
|
+
buf.push("[".concat(segmentsString(segment.segments), "]"));
|
|
3769
|
+
}
|
|
3770
|
+
else if (isString(segment)) {
|
|
3771
|
+
if (segment.match(RE_PROPERTY)) {
|
|
3772
|
+
buf.push(".".concat(segment));
|
|
3773
|
+
}
|
|
3774
|
+
else {
|
|
3775
|
+
buf.push("['".concat(segment, "']"));
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
else {
|
|
3779
|
+
buf.push("[".concat(segment, "]"));
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
3784
|
+
finally {
|
|
3785
|
+
try {
|
|
3786
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3787
|
+
}
|
|
3788
|
+
finally { if (e_17) throw e_17.error; }
|
|
3789
|
+
}
|
|
3790
|
+
return buf.join('');
|
|
3791
|
+
}
|
|
3792
|
+
|
|
3793
|
+
var LookupType;
|
|
3794
|
+
(function (LookupType) {
|
|
3795
|
+
LookupType["Partials"] = "partials";
|
|
3796
|
+
LookupType["Layouts"] = "layouts";
|
|
3797
|
+
LookupType["Root"] = "root";
|
|
3798
|
+
})(LookupType || (LookupType = {}));
|
|
3799
|
+
var Loader = /** @class */ (function () {
|
|
3800
|
+
function Loader(options) {
|
|
3801
|
+
this.options = options;
|
|
3802
|
+
if (options.relativeReference) {
|
|
3803
|
+
var sep = options.fs.sep;
|
|
3804
|
+
assert(sep, '`fs.sep` is required for relative reference');
|
|
3805
|
+
var rRelativePath_1 = new RegExp(['.' + sep, '..' + sep, './', '../'].map(function (prefix) { return escapeRegex(prefix); }).join('|'));
|
|
3806
|
+
this.shouldLoadRelative = function (referencedFile) { return rRelativePath_1.test(referencedFile); };
|
|
3807
|
+
}
|
|
3808
|
+
else {
|
|
3809
|
+
this.shouldLoadRelative = function (_referencedFile) { return false; };
|
|
3810
|
+
}
|
|
3811
|
+
this.contains = this.options.fs.contains || (function () { return true; });
|
|
3812
|
+
}
|
|
3813
|
+
Loader.prototype.lookup = function (file, type, sync, currentFile) {
|
|
3814
|
+
var fs, dirs, _a, _b, filepath, _c, e_1_1;
|
|
3815
|
+
var e_1, _d;
|
|
3816
|
+
return __generator(this, function (_e) {
|
|
3817
|
+
switch (_e.label) {
|
|
3818
|
+
case 0:
|
|
3819
|
+
fs = this.options.fs;
|
|
3820
|
+
dirs = this.options[type];
|
|
3821
|
+
_e.label = 1;
|
|
3822
|
+
case 1:
|
|
3823
|
+
_e.trys.push([1, 8, 9, 10]);
|
|
3824
|
+
_a = __values(this.candidates(file, dirs, currentFile, type !== LookupType.Root)), _b = _a.next();
|
|
3825
|
+
_e.label = 2;
|
|
3826
|
+
case 2:
|
|
3827
|
+
if (!!_b.done) return [3 /*break*/, 7];
|
|
3828
|
+
filepath = _b.value;
|
|
3829
|
+
if (!sync) return [3 /*break*/, 3];
|
|
3830
|
+
_c = fs.existsSync(filepath);
|
|
3831
|
+
return [3 /*break*/, 5];
|
|
3832
|
+
case 3: return [4 /*yield*/, fs.exists(filepath)];
|
|
3833
|
+
case 4:
|
|
3834
|
+
_c = _e.sent();
|
|
3835
|
+
_e.label = 5;
|
|
3836
|
+
case 5:
|
|
3837
|
+
if (_c)
|
|
3838
|
+
return [2 /*return*/, filepath];
|
|
3839
|
+
_e.label = 6;
|
|
3840
|
+
case 6:
|
|
3841
|
+
_b = _a.next();
|
|
3842
|
+
return [3 /*break*/, 2];
|
|
3843
|
+
case 7: return [3 /*break*/, 10];
|
|
3844
|
+
case 8:
|
|
3845
|
+
e_1_1 = _e.sent();
|
|
3846
|
+
e_1 = { error: e_1_1 };
|
|
3847
|
+
return [3 /*break*/, 10];
|
|
3848
|
+
case 9:
|
|
3849
|
+
try {
|
|
3850
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
3851
|
+
}
|
|
3852
|
+
finally { if (e_1) throw e_1.error; }
|
|
3853
|
+
return [7 /*endfinally*/];
|
|
3854
|
+
case 10: throw this.lookupError(file, dirs);
|
|
3855
|
+
}
|
|
3856
|
+
});
|
|
3857
|
+
};
|
|
3858
|
+
Loader.prototype.candidates = function (file, dirs, currentFile, enforceRoot) {
|
|
3859
|
+
var _a, fs, extname, referenced, dirs_1, dirs_1_1, dir, e_2_1, dirs_2, dirs_2_1, dir, referenced, e_3_1, filepath;
|
|
3860
|
+
var e_2, _b, e_3, _c;
|
|
3861
|
+
return __generator(this, function (_d) {
|
|
3862
|
+
switch (_d.label) {
|
|
3863
|
+
case 0:
|
|
3864
|
+
_a = this.options, fs = _a.fs, extname = _a.extname;
|
|
3865
|
+
if (!(this.shouldLoadRelative(file) && currentFile)) return [3 /*break*/, 8];
|
|
3866
|
+
referenced = fs.resolve(this.dirname(currentFile), file, extname);
|
|
3867
|
+
_d.label = 1;
|
|
3868
|
+
case 1:
|
|
3869
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
3870
|
+
dirs_1 = __values(dirs), dirs_1_1 = dirs_1.next();
|
|
3871
|
+
_d.label = 2;
|
|
3872
|
+
case 2:
|
|
3873
|
+
if (!!dirs_1_1.done) return [3 /*break*/, 5];
|
|
2974
3874
|
dir = dirs_1_1.value;
|
|
2975
3875
|
if (!(!enforceRoot || this.contains(dir, referenced))) return [3 /*break*/, 4];
|
|
2976
3876
|
// the relatively referenced file is within one of root dirs
|
|
@@ -3053,8 +3953,11 @@
|
|
|
3053
3953
|
this.fs = this.liquid.options.fs;
|
|
3054
3954
|
this.parseFile = this.cache ? this._parseFileCached : this._parseFile;
|
|
3055
3955
|
this.loader = new Loader(this.liquid.options);
|
|
3956
|
+
this.parseLimit = new Limiter('parse length', liquid.options.parseLimit);
|
|
3056
3957
|
}
|
|
3057
3958
|
Parser.prototype.parse = function (html, filepath) {
|
|
3959
|
+
html = String(html);
|
|
3960
|
+
this.parseLimit.use(html.length);
|
|
3058
3961
|
var tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath);
|
|
3059
3962
|
var tokens = tokenizer.readTopLevelTokens(this.liquid.options);
|
|
3060
3963
|
return this.parseTokens(tokens);
|
|
@@ -3062,9 +3965,20 @@
|
|
|
3062
3965
|
Parser.prototype.parseTokens = function (tokens) {
|
|
3063
3966
|
var token;
|
|
3064
3967
|
var templates = [];
|
|
3968
|
+
var errors = [];
|
|
3065
3969
|
while ((token = tokens.shift())) {
|
|
3066
|
-
|
|
3970
|
+
try {
|
|
3971
|
+
templates.push(this.parseToken(token, tokens));
|
|
3972
|
+
}
|
|
3973
|
+
catch (err) {
|
|
3974
|
+
if (this.liquid.options.catchAllErrors)
|
|
3975
|
+
errors.push(err);
|
|
3976
|
+
else
|
|
3977
|
+
throw err;
|
|
3978
|
+
}
|
|
3067
3979
|
}
|
|
3980
|
+
if (errors.length)
|
|
3981
|
+
throw new LiquidErrors(errors);
|
|
3068
3982
|
return templates;
|
|
3069
3983
|
};
|
|
3070
3984
|
Parser.prototype.parseToken = function (token, remainTokens) {
|
|
@@ -3072,7 +3986,7 @@
|
|
|
3072
3986
|
if (isTagToken(token)) {
|
|
3073
3987
|
var TagClass = this.liquid.tags[token.name];
|
|
3074
3988
|
assert(TagClass, "tag \"".concat(token.name, "\" not found"));
|
|
3075
|
-
return new TagClass(token, remainTokens, this.liquid);
|
|
3989
|
+
return new TagClass(token, remainTokens, this.liquid, this);
|
|
3076
3990
|
}
|
|
3077
3991
|
if (isOutputToken(token)) {
|
|
3078
3992
|
return new Output(token, this.liquid);
|
|
@@ -3128,22 +4042,22 @@
|
|
|
3128
4042
|
});
|
|
3129
4043
|
};
|
|
3130
4044
|
Parser.prototype._parseFile = function (file, sync, type, currentFile) {
|
|
3131
|
-
var filepath, _a, _b
|
|
4045
|
+
var filepath, _a, _b;
|
|
3132
4046
|
if (type === void 0) { type = LookupType.Root; }
|
|
3133
|
-
return __generator(this, function (
|
|
3134
|
-
switch (
|
|
4047
|
+
return __generator(this, function (_c) {
|
|
4048
|
+
switch (_c.label) {
|
|
3135
4049
|
case 0: return [4 /*yield*/, this.loader.lookup(file, type, sync, currentFile)];
|
|
3136
4050
|
case 1:
|
|
3137
|
-
filepath =
|
|
3138
|
-
|
|
4051
|
+
filepath = _c.sent();
|
|
4052
|
+
_a = this.parse;
|
|
3139
4053
|
if (!sync) return [3 /*break*/, 2];
|
|
3140
|
-
|
|
4054
|
+
_b = this.fs.readFileSync(filepath);
|
|
3141
4055
|
return [3 /*break*/, 4];
|
|
3142
4056
|
case 2: return [4 /*yield*/, this.fs.readFile(filepath)];
|
|
3143
4057
|
case 3:
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
case 4: return [2 /*return*/,
|
|
4058
|
+
_b = _c.sent();
|
|
4059
|
+
_c.label = 4;
|
|
4060
|
+
case 4: return [2 /*return*/, _a.apply(this, [_b, filepath])];
|
|
3147
4061
|
}
|
|
3148
4062
|
});
|
|
3149
4063
|
};
|
|
@@ -3200,6 +4114,10 @@
|
|
|
3200
4114
|
function isRangeToken(val) {
|
|
3201
4115
|
return getKind(val) === exports.TokenKind.Range;
|
|
3202
4116
|
}
|
|
4117
|
+
function isValueToken(val) {
|
|
4118
|
+
// valueTokenBitMask = TokenKind.Number | TokenKind.Literal | TokenKind.Quoted | TokenKind.PropertyAccess | TokenKind.Range
|
|
4119
|
+
return (getKind(val) & 1667) > 0;
|
|
4120
|
+
}
|
|
3203
4121
|
function getKind(val) {
|
|
3204
4122
|
return val ? val.kind : -1;
|
|
3205
4123
|
}
|
|
@@ -3216,27 +4134,33 @@
|
|
|
3216
4134
|
isNumberToken: isNumberToken,
|
|
3217
4135
|
isPropertyAccessToken: isPropertyAccessToken,
|
|
3218
4136
|
isWordToken: isWordToken,
|
|
3219
|
-
isRangeToken: isRangeToken
|
|
4137
|
+
isRangeToken: isRangeToken,
|
|
4138
|
+
isValueToken: isValueToken
|
|
3220
4139
|
});
|
|
3221
4140
|
|
|
3222
4141
|
var Context = /** @class */ (function () {
|
|
3223
|
-
function Context(env, opts, renderOptions) {
|
|
4142
|
+
function Context(env, opts, renderOptions, _a) {
|
|
3224
4143
|
if (env === void 0) { env = {}; }
|
|
3225
4144
|
if (opts === void 0) { opts = defaultOptions; }
|
|
3226
4145
|
if (renderOptions === void 0) { renderOptions = {}; }
|
|
3227
|
-
var _a, _b,
|
|
4146
|
+
var _b = _a === void 0 ? {} : _a, memoryLimit = _b.memoryLimit, renderLimit = _b.renderLimit;
|
|
4147
|
+
var _c, _d, _e, _f, _g;
|
|
3228
4148
|
/**
|
|
3229
4149
|
* insert a Context-level empty scope,
|
|
3230
4150
|
* for tags like `{% capture %}` `{% assign %}` to operate
|
|
3231
4151
|
*/
|
|
3232
4152
|
this.scopes = [{}];
|
|
3233
4153
|
this.registers = {};
|
|
4154
|
+
this.breakCalled = false;
|
|
4155
|
+
this.continueCalled = false;
|
|
3234
4156
|
this.sync = !!renderOptions.sync;
|
|
3235
4157
|
this.opts = opts;
|
|
3236
|
-
this.globals = (
|
|
4158
|
+
this.globals = (_c = renderOptions.globals) !== null && _c !== void 0 ? _c : opts.globals;
|
|
3237
4159
|
this.environments = isObject(env) ? env : Object(env);
|
|
3238
|
-
this.strictVariables = (
|
|
3239
|
-
this.ownPropertyOnly = (
|
|
4160
|
+
this.strictVariables = (_d = renderOptions.strictVariables) !== null && _d !== void 0 ? _d : this.opts.strictVariables;
|
|
4161
|
+
this.ownPropertyOnly = (_e = renderOptions.ownPropertyOnly) !== null && _e !== void 0 ? _e : opts.ownPropertyOnly;
|
|
4162
|
+
this.memoryLimit = memoryLimit !== null && memoryLimit !== void 0 ? memoryLimit : new Limiter('memory alloc', (_f = renderOptions.memoryLimit) !== null && _f !== void 0 ? _f : opts.memoryLimit);
|
|
4163
|
+
this.renderLimit = renderLimit !== null && renderLimit !== void 0 ? renderLimit : new Limiter('template render', getPerformance().now() + ((_g = renderOptions.renderLimit) !== null && _g !== void 0 ? _g : opts.renderLimit));
|
|
3240
4164
|
}
|
|
3241
4165
|
Context.prototype.getRegister = function (key) {
|
|
3242
4166
|
return (this.registers[key] = this.registers[key] || {});
|
|
@@ -3276,9 +4200,11 @@
|
|
|
3276
4200
|
return __generator(this, function (_a) {
|
|
3277
4201
|
switch (_a.label) {
|
|
3278
4202
|
case 0:
|
|
3279
|
-
scope = this.findScope(paths[0])
|
|
4203
|
+
scope = this.findScope(paths[0]) // first prop should always be a string
|
|
4204
|
+
;
|
|
3280
4205
|
return [4 /*yield*/, this._getFromScope(scope, paths)];
|
|
3281
|
-
case 1:
|
|
4206
|
+
case 1: // first prop should always be a string
|
|
4207
|
+
return [2 /*return*/, _a.sent()];
|
|
3282
4208
|
}
|
|
3283
4209
|
});
|
|
3284
4210
|
};
|
|
@@ -3323,6 +4249,17 @@
|
|
|
3323
4249
|
Context.prototype.bottom = function () {
|
|
3324
4250
|
return this.scopes[0];
|
|
3325
4251
|
};
|
|
4252
|
+
Context.prototype.spawn = function (scope) {
|
|
4253
|
+
if (scope === void 0) { scope = {}; }
|
|
4254
|
+
return new Context(scope, this.opts, {
|
|
4255
|
+
sync: this.sync,
|
|
4256
|
+
globals: this.globals,
|
|
4257
|
+
strictVariables: this.strictVariables
|
|
4258
|
+
}, {
|
|
4259
|
+
renderLimit: this.renderLimit,
|
|
4260
|
+
memoryLimit: this.memoryLimit
|
|
4261
|
+
});
|
|
4262
|
+
};
|
|
3326
4263
|
Context.prototype.findScope = function (key) {
|
|
3327
4264
|
for (var i = this.scopes.length - 1; i >= 0; i--) {
|
|
3328
4265
|
var candidate = this.scopes[i];
|
|
@@ -3337,6 +4274,7 @@
|
|
|
3337
4274
|
}());
|
|
3338
4275
|
function readProperty(obj, key, ownPropertyOnly) {
|
|
3339
4276
|
obj = toLiquid(obj);
|
|
4277
|
+
key = toValue(key);
|
|
3340
4278
|
if (isNil(obj))
|
|
3341
4279
|
return obj;
|
|
3342
4280
|
if (isArray(obj) && key < 0)
|
|
@@ -3355,7 +4293,7 @@
|
|
|
3355
4293
|
return value;
|
|
3356
4294
|
}
|
|
3357
4295
|
function readJSProperty(obj, key, ownPropertyOnly) {
|
|
3358
|
-
if (ownPropertyOnly && !
|
|
4296
|
+
if (ownPropertyOnly && !hasOwnProperty.call(obj, key) && !(obj instanceof Drop))
|
|
3359
4297
|
return undefined;
|
|
3360
4298
|
return obj[key];
|
|
3361
4299
|
}
|
|
@@ -3370,7 +4308,7 @@
|
|
|
3370
4308
|
return obj['last'];
|
|
3371
4309
|
}
|
|
3372
4310
|
function readSize(obj) {
|
|
3373
|
-
if (
|
|
4311
|
+
if (hasOwnProperty.call(obj, 'size') || obj['size'] !== undefined)
|
|
3374
4312
|
return obj['size'];
|
|
3375
4313
|
if (isArray(obj) || isString(obj))
|
|
3376
4314
|
return obj.length;
|
|
@@ -3483,51 +4421,63 @@
|
|
|
3483
4421
|
slugify: slugify
|
|
3484
4422
|
});
|
|
3485
4423
|
|
|
3486
|
-
var join = argumentsToValue(function (v, arg) {
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
4424
|
+
var join = argumentsToValue(function (v, arg) {
|
|
4425
|
+
var array = toArray(v);
|
|
4426
|
+
var sep = isNil(arg) ? ' ' : stringify(arg);
|
|
4427
|
+
var complexity = array.length * (1 + sep.length);
|
|
4428
|
+
this.context.memoryLimit.use(complexity);
|
|
4429
|
+
return array.join(sep);
|
|
4430
|
+
});
|
|
4431
|
+
var last$1 = argumentsToValue(function (v) { return isArrayLike(v) ? last(v) : ''; });
|
|
4432
|
+
var first = argumentsToValue(function (v) { return isArrayLike(v) ? v[0] : ''; });
|
|
4433
|
+
var reverse = argumentsToValue(function (v) {
|
|
4434
|
+
var array = toArray(v);
|
|
4435
|
+
this.context.memoryLimit.use(array.length);
|
|
4436
|
+
return __spreadArray([], __read(array), false).reverse();
|
|
4437
|
+
});
|
|
3490
4438
|
function sort(arr, property) {
|
|
3491
|
-
var values,
|
|
3492
|
-
var e_1,
|
|
3493
|
-
return __generator(this, function (
|
|
3494
|
-
switch (
|
|
4439
|
+
var values, array, array_1, array_1_1, item, _a, _b, _c, _d, e_1_1;
|
|
4440
|
+
var e_1, _e;
|
|
4441
|
+
return __generator(this, function (_f) {
|
|
4442
|
+
switch (_f.label) {
|
|
3495
4443
|
case 0:
|
|
3496
4444
|
values = [];
|
|
3497
|
-
|
|
4445
|
+
array = toArray(arr);
|
|
4446
|
+
this.context.memoryLimit.use(array.length);
|
|
4447
|
+
_f.label = 1;
|
|
3498
4448
|
case 1:
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
4449
|
+
_f.trys.push([1, 8, 9, 10]);
|
|
4450
|
+
array_1 = __values(array), array_1_1 = array_1.next();
|
|
4451
|
+
_f.label = 2;
|
|
3502
4452
|
case 2:
|
|
3503
|
-
if (!!
|
|
3504
|
-
item =
|
|
3505
|
-
|
|
3506
|
-
|
|
4453
|
+
if (!!array_1_1.done) return [3 /*break*/, 7];
|
|
4454
|
+
item = array_1_1.value;
|
|
4455
|
+
_b = (_a = values).push;
|
|
4456
|
+
_c = [item];
|
|
3507
4457
|
if (!property) return [3 /*break*/, 4];
|
|
3508
4458
|
return [4 /*yield*/, this.context._getFromScope(item, stringify(property).split('.'), false)];
|
|
3509
4459
|
case 3:
|
|
3510
|
-
|
|
4460
|
+
_d = _f.sent();
|
|
3511
4461
|
return [3 /*break*/, 5];
|
|
3512
4462
|
case 4:
|
|
3513
|
-
|
|
3514
|
-
|
|
4463
|
+
_d = item;
|
|
4464
|
+
_f.label = 5;
|
|
3515
4465
|
case 5:
|
|
3516
|
-
|
|
3517
|
-
|
|
4466
|
+
_b.apply(_a, [_c.concat([
|
|
4467
|
+
_d
|
|
3518
4468
|
])]);
|
|
3519
|
-
|
|
4469
|
+
_f.label = 6;
|
|
3520
4470
|
case 6:
|
|
3521
|
-
|
|
4471
|
+
array_1_1 = array_1.next();
|
|
3522
4472
|
return [3 /*break*/, 2];
|
|
3523
4473
|
case 7: return [3 /*break*/, 10];
|
|
3524
4474
|
case 8:
|
|
3525
|
-
e_1_1 =
|
|
4475
|
+
e_1_1 = _f.sent();
|
|
3526
4476
|
e_1 = { error: e_1_1 };
|
|
3527
4477
|
return [3 /*break*/, 10];
|
|
3528
4478
|
case 9:
|
|
3529
4479
|
try {
|
|
3530
|
-
if (
|
|
4480
|
+
if (array_1_1 && !array_1_1.done && (_e = array_1.return)) _e.call(array_1);
|
|
3531
4481
|
}
|
|
3532
4482
|
finally { if (e_1) throw e_1.error; }
|
|
3533
4483
|
return [7 /*endfinally*/];
|
|
@@ -3544,40 +4494,44 @@
|
|
|
3544
4494
|
var compare = property === undefined
|
|
3545
4495
|
? caseInsensitiveCompare
|
|
3546
4496
|
: function (lhs, rhs) { return caseInsensitiveCompare(lhs[propertyString], rhs[propertyString]); };
|
|
3547
|
-
|
|
4497
|
+
var array = toArray(input);
|
|
4498
|
+
this.context.memoryLimit.use(array.length);
|
|
4499
|
+
return __spreadArray([], __read(array), false).sort(compare);
|
|
3548
4500
|
}
|
|
3549
4501
|
var size = function (v) { return (v && v.length) || 0; };
|
|
3550
4502
|
function map(arr, property) {
|
|
3551
|
-
var results,
|
|
3552
|
-
var e_2,
|
|
3553
|
-
return __generator(this, function (
|
|
3554
|
-
switch (
|
|
4503
|
+
var results, array, array_2, array_2_1, item, _a, _b, e_2_1;
|
|
4504
|
+
var e_2, _c;
|
|
4505
|
+
return __generator(this, function (_d) {
|
|
4506
|
+
switch (_d.label) {
|
|
3555
4507
|
case 0:
|
|
3556
4508
|
results = [];
|
|
3557
|
-
|
|
4509
|
+
array = toArray(arr);
|
|
4510
|
+
this.context.memoryLimit.use(array.length);
|
|
4511
|
+
_d.label = 1;
|
|
3558
4512
|
case 1:
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
4513
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
4514
|
+
array_2 = __values(array), array_2_1 = array_2.next();
|
|
4515
|
+
_d.label = 2;
|
|
3562
4516
|
case 2:
|
|
3563
|
-
if (!!
|
|
3564
|
-
item =
|
|
3565
|
-
|
|
4517
|
+
if (!!array_2_1.done) return [3 /*break*/, 5];
|
|
4518
|
+
item = array_2_1.value;
|
|
4519
|
+
_b = (_a = results).push;
|
|
3566
4520
|
return [4 /*yield*/, this.context._getFromScope(item, stringify(property), false)];
|
|
3567
4521
|
case 3:
|
|
3568
|
-
|
|
3569
|
-
|
|
4522
|
+
_b.apply(_a, [_d.sent()]);
|
|
4523
|
+
_d.label = 4;
|
|
3570
4524
|
case 4:
|
|
3571
|
-
|
|
4525
|
+
array_2_1 = array_2.next();
|
|
3572
4526
|
return [3 /*break*/, 2];
|
|
3573
4527
|
case 5: return [3 /*break*/, 8];
|
|
3574
4528
|
case 6:
|
|
3575
|
-
e_2_1 =
|
|
4529
|
+
e_2_1 = _d.sent();
|
|
3576
4530
|
e_2 = { error: e_2_1 };
|
|
3577
4531
|
return [3 /*break*/, 8];
|
|
3578
4532
|
case 7:
|
|
3579
4533
|
try {
|
|
3580
|
-
if (
|
|
4534
|
+
if (array_2_1 && !array_2_1.done && (_c = array_2.return)) _c.call(array_2);
|
|
3581
4535
|
}
|
|
3582
4536
|
finally { if (e_2) throw e_2.error; }
|
|
3583
4537
|
return [7 /*endfinally*/];
|
|
@@ -3586,44 +4540,45 @@
|
|
|
3586
4540
|
});
|
|
3587
4541
|
}
|
|
3588
4542
|
function sum(arr, property) {
|
|
3589
|
-
var sum,
|
|
3590
|
-
var e_3,
|
|
3591
|
-
return __generator(this, function (
|
|
3592
|
-
switch (
|
|
4543
|
+
var sum, array, array_3, array_3_1, item, data, _a, _b, e_3_1;
|
|
4544
|
+
var e_3, _c;
|
|
4545
|
+
return __generator(this, function (_d) {
|
|
4546
|
+
switch (_d.label) {
|
|
3593
4547
|
case 0:
|
|
3594
4548
|
sum = 0;
|
|
3595
|
-
|
|
4549
|
+
array = toArray(arr);
|
|
4550
|
+
_d.label = 1;
|
|
3596
4551
|
case 1:
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
4552
|
+
_d.trys.push([1, 8, 9, 10]);
|
|
4553
|
+
array_3 = __values(array), array_3_1 = array_3.next();
|
|
4554
|
+
_d.label = 2;
|
|
3600
4555
|
case 2:
|
|
3601
|
-
if (!!
|
|
3602
|
-
item =
|
|
3603
|
-
|
|
4556
|
+
if (!!array_3_1.done) return [3 /*break*/, 7];
|
|
4557
|
+
item = array_3_1.value;
|
|
4558
|
+
_a = Number;
|
|
3604
4559
|
if (!property) return [3 /*break*/, 4];
|
|
3605
4560
|
return [4 /*yield*/, this.context._getFromScope(item, stringify(property), false)];
|
|
3606
4561
|
case 3:
|
|
3607
|
-
|
|
4562
|
+
_b = _d.sent();
|
|
3608
4563
|
return [3 /*break*/, 5];
|
|
3609
4564
|
case 4:
|
|
3610
|
-
|
|
3611
|
-
|
|
4565
|
+
_b = item;
|
|
4566
|
+
_d.label = 5;
|
|
3612
4567
|
case 5:
|
|
3613
|
-
data =
|
|
4568
|
+
data = _a.apply(void 0, [_b]);
|
|
3614
4569
|
sum += Number.isNaN(data) ? 0 : data;
|
|
3615
|
-
|
|
4570
|
+
_d.label = 6;
|
|
3616
4571
|
case 6:
|
|
3617
|
-
|
|
4572
|
+
array_3_1 = array_3.next();
|
|
3618
4573
|
return [3 /*break*/, 2];
|
|
3619
4574
|
case 7: return [3 /*break*/, 10];
|
|
3620
4575
|
case 8:
|
|
3621
|
-
e_3_1 =
|
|
4576
|
+
e_3_1 = _d.sent();
|
|
3622
4577
|
e_3 = { error: e_3_1 };
|
|
3623
4578
|
return [3 /*break*/, 10];
|
|
3624
4579
|
case 9:
|
|
3625
4580
|
try {
|
|
3626
|
-
if (
|
|
4581
|
+
if (array_3_1 && !array_3_1.done && (_c = array_3.return)) _c.call(array_3);
|
|
3627
4582
|
}
|
|
3628
4583
|
finally { if (e_3) throw e_3.error; }
|
|
3629
4584
|
return [7 /*endfinally*/];
|
|
@@ -3632,17 +4587,24 @@
|
|
|
3632
4587
|
});
|
|
3633
4588
|
}
|
|
3634
4589
|
function compact(arr) {
|
|
3635
|
-
|
|
4590
|
+
var array = toArray(arr);
|
|
4591
|
+
this.context.memoryLimit.use(array.length);
|
|
4592
|
+
return array.filter(function (x) { return !isNil(toValue(x)); });
|
|
3636
4593
|
}
|
|
3637
4594
|
function concat(v, arg) {
|
|
3638
4595
|
if (arg === void 0) { arg = []; }
|
|
3639
|
-
|
|
4596
|
+
var lhs = toArray(v);
|
|
4597
|
+
var rhs = toArray(arg);
|
|
4598
|
+
this.context.memoryLimit.use(lhs.length + rhs.length);
|
|
4599
|
+
return lhs.concat(rhs);
|
|
3640
4600
|
}
|
|
3641
4601
|
function push(v, arg) {
|
|
3642
|
-
return concat(v, [arg]);
|
|
4602
|
+
return concat.call(this, v, [arg]);
|
|
3643
4603
|
}
|
|
3644
4604
|
function unshift(v, arg) {
|
|
3645
|
-
var
|
|
4605
|
+
var array = toArray(v);
|
|
4606
|
+
this.context.memoryLimit.use(array.length);
|
|
4607
|
+
var clone = __spreadArray([], __read(array), false);
|
|
3646
4608
|
clone.unshift(arg);
|
|
3647
4609
|
return clone;
|
|
3648
4610
|
}
|
|
@@ -3652,7 +4614,9 @@
|
|
|
3652
4614
|
return clone;
|
|
3653
4615
|
}
|
|
3654
4616
|
function shift(v) {
|
|
3655
|
-
var
|
|
4617
|
+
var array = toArray(v);
|
|
4618
|
+
this.context.memoryLimit.use(array.length);
|
|
4619
|
+
var clone = __spreadArray([], __read(array), false);
|
|
3656
4620
|
clone.shift();
|
|
3657
4621
|
return clone;
|
|
3658
4622
|
}
|
|
@@ -3664,10 +4628,11 @@
|
|
|
3664
4628
|
if (!isArray(v))
|
|
3665
4629
|
v = stringify(v);
|
|
3666
4630
|
begin = begin < 0 ? v.length + begin : begin;
|
|
4631
|
+
this.context.memoryLimit.use(length);
|
|
3667
4632
|
return v.slice(begin, begin + length);
|
|
3668
4633
|
}
|
|
3669
4634
|
function where(arr, property, expected) {
|
|
3670
|
-
var values, token, arr_1, arr_1_1, item, _a, _b, e_4_1;
|
|
4635
|
+
var values, token, arr_1, arr_1_1, item, _a, _b, e_4_1, matcher;
|
|
3671
4636
|
var e_4, _c;
|
|
3672
4637
|
var _this = this;
|
|
3673
4638
|
return __generator(this, function (_d) {
|
|
@@ -3675,6 +4640,7 @@
|
|
|
3675
4640
|
case 0:
|
|
3676
4641
|
values = [];
|
|
3677
4642
|
arr = toArray(arr);
|
|
4643
|
+
this.context.memoryLimit.use(arr.length);
|
|
3678
4644
|
token = new Tokenizer(stringify(property)).readScopeValue();
|
|
3679
4645
|
_d.label = 1;
|
|
3680
4646
|
case 1:
|
|
@@ -3685,7 +4651,7 @@
|
|
|
3685
4651
|
if (!!arr_1_1.done) return [3 /*break*/, 5];
|
|
3686
4652
|
item = arr_1_1.value;
|
|
3687
4653
|
_b = (_a = values).push;
|
|
3688
|
-
return [4 /*yield*/, evalToken(token,
|
|
4654
|
+
return [4 /*yield*/, evalToken(token, this.context.spawn(item))];
|
|
3689
4655
|
case 3:
|
|
3690
4656
|
_b.apply(_a, [_d.sent()]);
|
|
3691
4657
|
_d.label = 4;
|
|
@@ -3703,47 +4669,53 @@
|
|
|
3703
4669
|
}
|
|
3704
4670
|
finally { if (e_4) throw e_4.error; }
|
|
3705
4671
|
return [7 /*endfinally*/];
|
|
3706
|
-
case 8:
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
return equals(
|
|
3710
|
-
|
|
4672
|
+
case 8:
|
|
4673
|
+
matcher = this.context.opts.jekyllWhere
|
|
4674
|
+
? function (v) { return EmptyDrop.is(expected) ? equals(v, expected) : (isArray(v) ? arrayIncludes(v, expected) : equals(v, expected)); }
|
|
4675
|
+
: function (v) { return equals(v, expected); };
|
|
4676
|
+
return [2 /*return*/, arr.filter(function (_, i) {
|
|
4677
|
+
if (expected === undefined)
|
|
4678
|
+
return isTruthy(values[i], _this.context);
|
|
4679
|
+
return matcher(values[i]);
|
|
4680
|
+
})];
|
|
3711
4681
|
}
|
|
3712
4682
|
});
|
|
3713
4683
|
}
|
|
3714
4684
|
function where_exp(arr, itemName, exp) {
|
|
3715
|
-
var filtered, keyTemplate,
|
|
3716
|
-
var e_5,
|
|
3717
|
-
return __generator(this, function (
|
|
3718
|
-
switch (
|
|
4685
|
+
var filtered, keyTemplate, array, array_4, array_4_1, item, value, e_5_1;
|
|
4686
|
+
var e_5, _a, _b;
|
|
4687
|
+
return __generator(this, function (_c) {
|
|
4688
|
+
switch (_c.label) {
|
|
3719
4689
|
case 0:
|
|
3720
4690
|
filtered = [];
|
|
3721
4691
|
keyTemplate = new Value(stringify(exp), this.liquid);
|
|
3722
|
-
|
|
4692
|
+
array = toArray(arr);
|
|
4693
|
+
this.context.memoryLimit.use(array.length);
|
|
4694
|
+
_c.label = 1;
|
|
3723
4695
|
case 1:
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
4696
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
4697
|
+
array_4 = __values(array), array_4_1 = array_4.next();
|
|
4698
|
+
_c.label = 2;
|
|
3727
4699
|
case 2:
|
|
3728
|
-
if (!!
|
|
3729
|
-
item =
|
|
3730
|
-
return [4 /*yield*/, keyTemplate.value(
|
|
4700
|
+
if (!!array_4_1.done) return [3 /*break*/, 5];
|
|
4701
|
+
item = array_4_1.value;
|
|
4702
|
+
return [4 /*yield*/, keyTemplate.value(this.context.spawn((_b = {}, _b[itemName] = item, _b)))];
|
|
3731
4703
|
case 3:
|
|
3732
|
-
value =
|
|
4704
|
+
value = _c.sent();
|
|
3733
4705
|
if (value)
|
|
3734
4706
|
filtered.push(item);
|
|
3735
|
-
|
|
4707
|
+
_c.label = 4;
|
|
3736
4708
|
case 4:
|
|
3737
|
-
|
|
4709
|
+
array_4_1 = array_4.next();
|
|
3738
4710
|
return [3 /*break*/, 2];
|
|
3739
4711
|
case 5: return [3 /*break*/, 8];
|
|
3740
4712
|
case 6:
|
|
3741
|
-
e_5_1 =
|
|
4713
|
+
e_5_1 = _c.sent();
|
|
3742
4714
|
e_5 = { error: e_5_1 };
|
|
3743
4715
|
return [3 /*break*/, 8];
|
|
3744
4716
|
case 7:
|
|
3745
4717
|
try {
|
|
3746
|
-
if (
|
|
4718
|
+
if (array_4_1 && !array_4_1.done && (_a = array_4.return)) _a.call(array_4);
|
|
3747
4719
|
}
|
|
3748
4720
|
finally { if (e_5) throw e_5.error; }
|
|
3749
4721
|
return [7 /*endfinally*/];
|
|
@@ -3758,8 +4730,9 @@
|
|
|
3758
4730
|
switch (_b.label) {
|
|
3759
4731
|
case 0:
|
|
3760
4732
|
map = new Map();
|
|
3761
|
-
arr =
|
|
4733
|
+
arr = toEnumerable(arr);
|
|
3762
4734
|
token = new Tokenizer(stringify(property)).readScopeValue();
|
|
4735
|
+
this.context.memoryLimit.use(arr.length);
|
|
3763
4736
|
_b.label = 1;
|
|
3764
4737
|
case 1:
|
|
3765
4738
|
_b.trys.push([1, 6, 7, 8]);
|
|
@@ -3768,7 +4741,7 @@
|
|
|
3768
4741
|
case 2:
|
|
3769
4742
|
if (!!arr_2_1.done) return [3 /*break*/, 5];
|
|
3770
4743
|
item = arr_2_1.value;
|
|
3771
|
-
return [4 /*yield*/, evalToken(token,
|
|
4744
|
+
return [4 /*yield*/, evalToken(token, this.context.spawn(item))];
|
|
3772
4745
|
case 3:
|
|
3773
4746
|
key = _b.sent();
|
|
3774
4747
|
if (!map.has(key))
|
|
@@ -3797,39 +4770,41 @@
|
|
|
3797
4770
|
});
|
|
3798
4771
|
}
|
|
3799
4772
|
function group_by_exp(arr, itemName, exp) {
|
|
3800
|
-
var map, keyTemplate,
|
|
3801
|
-
var e_7,
|
|
3802
|
-
return __generator(this, function (
|
|
3803
|
-
switch (
|
|
4773
|
+
var map, keyTemplate, arr_3, arr_3_1, item, key, e_7_1;
|
|
4774
|
+
var e_7, _a, _b;
|
|
4775
|
+
return __generator(this, function (_c) {
|
|
4776
|
+
switch (_c.label) {
|
|
3804
4777
|
case 0:
|
|
3805
4778
|
map = new Map();
|
|
3806
4779
|
keyTemplate = new Value(stringify(exp), this.liquid);
|
|
3807
|
-
|
|
4780
|
+
arr = toEnumerable(arr);
|
|
4781
|
+
this.context.memoryLimit.use(arr.length);
|
|
4782
|
+
_c.label = 1;
|
|
3808
4783
|
case 1:
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
4784
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
4785
|
+
arr_3 = __values(arr), arr_3_1 = arr_3.next();
|
|
4786
|
+
_c.label = 2;
|
|
3812
4787
|
case 2:
|
|
3813
|
-
if (!!
|
|
3814
|
-
item =
|
|
3815
|
-
return [4 /*yield*/, keyTemplate.value(
|
|
4788
|
+
if (!!arr_3_1.done) return [3 /*break*/, 5];
|
|
4789
|
+
item = arr_3_1.value;
|
|
4790
|
+
return [4 /*yield*/, keyTemplate.value(this.context.spawn((_b = {}, _b[itemName] = item, _b)))];
|
|
3816
4791
|
case 3:
|
|
3817
|
-
key =
|
|
4792
|
+
key = _c.sent();
|
|
3818
4793
|
if (!map.has(key))
|
|
3819
4794
|
map.set(key, []);
|
|
3820
4795
|
map.get(key).push(item);
|
|
3821
|
-
|
|
4796
|
+
_c.label = 4;
|
|
3822
4797
|
case 4:
|
|
3823
|
-
|
|
4798
|
+
arr_3_1 = arr_3.next();
|
|
3824
4799
|
return [3 /*break*/, 2];
|
|
3825
4800
|
case 5: return [3 /*break*/, 8];
|
|
3826
4801
|
case 6:
|
|
3827
|
-
e_7_1 =
|
|
4802
|
+
e_7_1 = _c.sent();
|
|
3828
4803
|
e_7 = { error: e_7_1 };
|
|
3829
4804
|
return [3 /*break*/, 8];
|
|
3830
4805
|
case 7:
|
|
3831
4806
|
try {
|
|
3832
|
-
if (
|
|
4807
|
+
if (arr_3_1 && !arr_3_1.done && (_a = arr_3.return)) _a.call(arr_3);
|
|
3833
4808
|
}
|
|
3834
4809
|
finally { if (e_7) throw e_7.error; }
|
|
3835
4810
|
return [7 /*endfinally*/];
|
|
@@ -3841,92 +4816,89 @@
|
|
|
3841
4816
|
});
|
|
3842
4817
|
}
|
|
3843
4818
|
function find(arr, property, expected) {
|
|
3844
|
-
var token,
|
|
3845
|
-
var e_8,
|
|
3846
|
-
return __generator(this, function (
|
|
3847
|
-
switch (
|
|
4819
|
+
var token, array, array_5, array_5_1, item, value, e_8_1;
|
|
4820
|
+
var e_8, _a;
|
|
4821
|
+
return __generator(this, function (_b) {
|
|
4822
|
+
switch (_b.label) {
|
|
3848
4823
|
case 0:
|
|
3849
4824
|
token = new Tokenizer(stringify(property)).readScopeValue();
|
|
3850
|
-
|
|
4825
|
+
array = toArray(arr);
|
|
4826
|
+
_b.label = 1;
|
|
3851
4827
|
case 1:
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
4828
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
4829
|
+
array_5 = __values(array), array_5_1 = array_5.next();
|
|
4830
|
+
_b.label = 2;
|
|
3855
4831
|
case 2:
|
|
3856
|
-
if (!!
|
|
3857
|
-
item =
|
|
3858
|
-
return [4 /*yield*/, evalToken(token,
|
|
4832
|
+
if (!!array_5_1.done) return [3 /*break*/, 5];
|
|
4833
|
+
item = array_5_1.value;
|
|
4834
|
+
return [4 /*yield*/, evalToken(token, this.context.spawn(item))];
|
|
3859
4835
|
case 3:
|
|
3860
|
-
value =
|
|
4836
|
+
value = _b.sent();
|
|
3861
4837
|
if (equals(value, expected))
|
|
3862
4838
|
return [2 /*return*/, item];
|
|
3863
|
-
|
|
4839
|
+
_b.label = 4;
|
|
3864
4840
|
case 4:
|
|
3865
|
-
|
|
4841
|
+
array_5_1 = array_5.next();
|
|
3866
4842
|
return [3 /*break*/, 2];
|
|
3867
4843
|
case 5: return [3 /*break*/, 8];
|
|
3868
4844
|
case 6:
|
|
3869
|
-
e_8_1 =
|
|
4845
|
+
e_8_1 = _b.sent();
|
|
3870
4846
|
e_8 = { error: e_8_1 };
|
|
3871
4847
|
return [3 /*break*/, 8];
|
|
3872
4848
|
case 7:
|
|
3873
4849
|
try {
|
|
3874
|
-
if (
|
|
4850
|
+
if (array_5_1 && !array_5_1.done && (_a = array_5.return)) _a.call(array_5);
|
|
3875
4851
|
}
|
|
3876
4852
|
finally { if (e_8) throw e_8.error; }
|
|
3877
4853
|
return [7 /*endfinally*/];
|
|
3878
|
-
case 8: return [2 /*return
|
|
4854
|
+
case 8: return [2 /*return*/];
|
|
3879
4855
|
}
|
|
3880
4856
|
});
|
|
3881
4857
|
}
|
|
3882
4858
|
function find_exp(arr, itemName, exp) {
|
|
3883
|
-
var predicate,
|
|
3884
|
-
var e_9,
|
|
3885
|
-
return __generator(this, function (
|
|
3886
|
-
switch (
|
|
4859
|
+
var predicate, array, array_6, array_6_1, item, value, e_9_1;
|
|
4860
|
+
var e_9, _a, _b;
|
|
4861
|
+
return __generator(this, function (_c) {
|
|
4862
|
+
switch (_c.label) {
|
|
3887
4863
|
case 0:
|
|
3888
4864
|
predicate = new Value(stringify(exp), this.liquid);
|
|
3889
|
-
|
|
4865
|
+
array = toArray(arr);
|
|
4866
|
+
_c.label = 1;
|
|
3890
4867
|
case 1:
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
4868
|
+
_c.trys.push([1, 6, 7, 8]);
|
|
4869
|
+
array_6 = __values(array), array_6_1 = array_6.next();
|
|
4870
|
+
_c.label = 2;
|
|
3894
4871
|
case 2:
|
|
3895
|
-
if (!!
|
|
3896
|
-
item =
|
|
3897
|
-
return [4 /*yield*/, predicate.value(
|
|
4872
|
+
if (!!array_6_1.done) return [3 /*break*/, 5];
|
|
4873
|
+
item = array_6_1.value;
|
|
4874
|
+
return [4 /*yield*/, predicate.value(this.context.spawn((_b = {}, _b[itemName] = item, _b)))];
|
|
3898
4875
|
case 3:
|
|
3899
|
-
value =
|
|
4876
|
+
value = _c.sent();
|
|
3900
4877
|
if (value)
|
|
3901
4878
|
return [2 /*return*/, item];
|
|
3902
|
-
|
|
4879
|
+
_c.label = 4;
|
|
3903
4880
|
case 4:
|
|
3904
|
-
|
|
4881
|
+
array_6_1 = array_6.next();
|
|
3905
4882
|
return [3 /*break*/, 2];
|
|
3906
4883
|
case 5: return [3 /*break*/, 8];
|
|
3907
4884
|
case 6:
|
|
3908
|
-
e_9_1 =
|
|
4885
|
+
e_9_1 = _c.sent();
|
|
3909
4886
|
e_9 = { error: e_9_1 };
|
|
3910
4887
|
return [3 /*break*/, 8];
|
|
3911
4888
|
case 7:
|
|
3912
4889
|
try {
|
|
3913
|
-
if (
|
|
4890
|
+
if (array_6_1 && !array_6_1.done && (_a = array_6.return)) _a.call(array_6);
|
|
3914
4891
|
}
|
|
3915
4892
|
finally { if (e_9) throw e_9.error; }
|
|
3916
4893
|
return [7 /*endfinally*/];
|
|
3917
|
-
case 8: return [2 /*return
|
|
4894
|
+
case 8: return [2 /*return*/];
|
|
3918
4895
|
}
|
|
3919
4896
|
});
|
|
3920
4897
|
}
|
|
3921
4898
|
function uniq(arr) {
|
|
3922
|
-
arr =
|
|
3923
|
-
|
|
3924
|
-
return (
|
|
3925
|
-
if (hasOwnProperty.call(u, String(val)))
|
|
3926
|
-
return false;
|
|
3927
|
-
u[String(val)] = true;
|
|
3928
|
-
return true;
|
|
3929
|
-
});
|
|
4899
|
+
arr = toArray(arr);
|
|
4900
|
+
this.context.memoryLimit.use(arr.length);
|
|
4901
|
+
return __spreadArray([], __read(new Set(arr)), false);
|
|
3930
4902
|
}
|
|
3931
4903
|
function sample(v, count) {
|
|
3932
4904
|
if (count === void 0) { count = 1; }
|
|
@@ -3935,6 +4907,7 @@
|
|
|
3935
4907
|
return [];
|
|
3936
4908
|
if (!isArray(v))
|
|
3937
4909
|
v = stringify(v);
|
|
4910
|
+
this.context.memoryLimit.use(count);
|
|
3938
4911
|
var shuffled = __spreadArray([], __read(v), false).sort(function () { return Math.random() - 0.5; });
|
|
3939
4912
|
if (count === 1)
|
|
3940
4913
|
return shuffled[0];
|
|
@@ -3970,6 +4943,9 @@
|
|
|
3970
4943
|
});
|
|
3971
4944
|
|
|
3972
4945
|
function date(v, format, timezoneOffset) {
|
|
4946
|
+
var _a, _b, _c;
|
|
4947
|
+
var size = ((_a = v === null || v === void 0 ? void 0 : v.length) !== null && _a !== void 0 ? _a : 0) + ((_b = format === null || format === void 0 ? void 0 : format.length) !== null && _b !== void 0 ? _b : 0) + ((_c = timezoneOffset === null || timezoneOffset === void 0 ? void 0 : timezoneOffset.length) !== null && _c !== void 0 ? _c : 0);
|
|
4948
|
+
this.context.memoryLimit.use(size);
|
|
3973
4949
|
var date = parseDate(v, this.context.opts, timezoneOffset);
|
|
3974
4950
|
if (!date)
|
|
3975
4951
|
return v;
|
|
@@ -4003,39 +4979,30 @@
|
|
|
4003
4979
|
}
|
|
4004
4980
|
function parseDate(v, opts, timezoneOffset) {
|
|
4005
4981
|
var date;
|
|
4982
|
+
var defaultTimezoneOffset = timezoneOffset !== null && timezoneOffset !== void 0 ? timezoneOffset : opts.timezoneOffset;
|
|
4983
|
+
var locale = opts.locale;
|
|
4006
4984
|
v = toValue(v);
|
|
4007
4985
|
if (v === 'now' || v === 'today') {
|
|
4008
|
-
date = new Date();
|
|
4986
|
+
date = new LiquidDate(Date.now(), locale, defaultTimezoneOffset);
|
|
4009
4987
|
}
|
|
4010
4988
|
else if (isNumber(v)) {
|
|
4011
|
-
date = new
|
|
4989
|
+
date = new LiquidDate(v * 1000, locale, defaultTimezoneOffset);
|
|
4012
4990
|
}
|
|
4013
4991
|
else if (isString(v)) {
|
|
4014
4992
|
if (/^\d+$/.test(v)) {
|
|
4015
|
-
date = new
|
|
4993
|
+
date = new LiquidDate(+v * 1000, locale, defaultTimezoneOffset);
|
|
4016
4994
|
}
|
|
4017
|
-
else if (opts.preserveTimezones) {
|
|
4018
|
-
date =
|
|
4995
|
+
else if (opts.preserveTimezones && timezoneOffset === undefined) {
|
|
4996
|
+
date = LiquidDate.createDateFixedToTimezone(v, locale);
|
|
4019
4997
|
}
|
|
4020
4998
|
else {
|
|
4021
|
-
date = new
|
|
4999
|
+
date = new LiquidDate(v, locale, defaultTimezoneOffset);
|
|
4022
5000
|
}
|
|
4023
5001
|
}
|
|
4024
5002
|
else {
|
|
4025
|
-
date = v;
|
|
5003
|
+
date = new LiquidDate(v, locale, defaultTimezoneOffset);
|
|
4026
5004
|
}
|
|
4027
|
-
|
|
4028
|
-
return;
|
|
4029
|
-
if (timezoneOffset !== undefined) {
|
|
4030
|
-
date = new TimezoneDate(date, timezoneOffset);
|
|
4031
|
-
}
|
|
4032
|
-
else if (!(date instanceof TimezoneDate) && opts.timezoneOffset !== undefined) {
|
|
4033
|
-
date = new TimezoneDate(date, opts.timezoneOffset);
|
|
4034
|
-
}
|
|
4035
|
-
return date;
|
|
4036
|
-
}
|
|
4037
|
-
function isValidDate(date) {
|
|
4038
|
-
return (date instanceof Date || date instanceof TimezoneDate) && !isNaN(date.getTime());
|
|
5005
|
+
return date.valid() ? date : undefined;
|
|
4039
5006
|
}
|
|
4040
5007
|
|
|
4041
5008
|
var dateFilters = /*#__PURE__*/Object.freeze({
|
|
@@ -4057,33 +5024,50 @@
|
|
|
4057
5024
|
var rNonCJKWord = /[^\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF\s]+/gu;
|
|
4058
5025
|
function append(v, arg) {
|
|
4059
5026
|
assert(arguments.length === 2, 'append expect 2 arguments');
|
|
4060
|
-
|
|
5027
|
+
var lhs = stringify(v);
|
|
5028
|
+
var rhs = stringify(arg);
|
|
5029
|
+
this.context.memoryLimit.use(lhs.length + rhs.length);
|
|
5030
|
+
return lhs + rhs;
|
|
4061
5031
|
}
|
|
4062
5032
|
function prepend(v, arg) {
|
|
4063
5033
|
assert(arguments.length === 2, 'prepend expect 2 arguments');
|
|
4064
|
-
|
|
5034
|
+
var lhs = stringify(v);
|
|
5035
|
+
var rhs = stringify(arg);
|
|
5036
|
+
this.context.memoryLimit.use(lhs.length + rhs.length);
|
|
5037
|
+
return rhs + lhs;
|
|
4065
5038
|
}
|
|
4066
5039
|
function lstrip(v, chars) {
|
|
5040
|
+
var str = stringify(v);
|
|
5041
|
+
this.context.memoryLimit.use(str.length);
|
|
4067
5042
|
if (chars) {
|
|
4068
5043
|
chars = escapeRegExp(stringify(chars));
|
|
4069
|
-
return
|
|
5044
|
+
return str.replace(new RegExp("^[".concat(chars, "]+"), 'g'), '');
|
|
4070
5045
|
}
|
|
4071
|
-
return
|
|
5046
|
+
return str.replace(/^\s+/, '');
|
|
4072
5047
|
}
|
|
4073
5048
|
function downcase(v) {
|
|
4074
|
-
|
|
5049
|
+
var str = stringify(v);
|
|
5050
|
+
this.context.memoryLimit.use(str.length);
|
|
5051
|
+
return str.toLowerCase();
|
|
4075
5052
|
}
|
|
4076
|
-
function upcase(
|
|
5053
|
+
function upcase(v) {
|
|
5054
|
+
var str = stringify(v);
|
|
5055
|
+
this.context.memoryLimit.use(str.length);
|
|
4077
5056
|
return stringify(str).toUpperCase();
|
|
4078
5057
|
}
|
|
4079
5058
|
function remove(v, arg) {
|
|
4080
|
-
|
|
5059
|
+
var str = stringify(v);
|
|
5060
|
+
this.context.memoryLimit.use(str.length);
|
|
5061
|
+
return str.split(stringify(arg)).join('');
|
|
4081
5062
|
}
|
|
4082
5063
|
function remove_first(v, l) {
|
|
4083
|
-
|
|
5064
|
+
var str = stringify(v);
|
|
5065
|
+
this.context.memoryLimit.use(str.length);
|
|
5066
|
+
return str.replace(stringify(l), '');
|
|
4084
5067
|
}
|
|
4085
5068
|
function remove_last(v, l) {
|
|
4086
5069
|
var str = stringify(v);
|
|
5070
|
+
this.context.memoryLimit.use(str.length);
|
|
4087
5071
|
var pattern = stringify(l);
|
|
4088
5072
|
var index = str.lastIndexOf(pattern);
|
|
4089
5073
|
if (index === -1)
|
|
@@ -4091,14 +5075,18 @@
|
|
|
4091
5075
|
return str.substring(0, index) + str.substring(index + pattern.length);
|
|
4092
5076
|
}
|
|
4093
5077
|
function rstrip(str, chars) {
|
|
5078
|
+
str = stringify(str);
|
|
5079
|
+
this.context.memoryLimit.use(str.length);
|
|
4094
5080
|
if (chars) {
|
|
4095
5081
|
chars = escapeRegExp(stringify(chars));
|
|
4096
|
-
return
|
|
5082
|
+
return str.replace(new RegExp("[".concat(chars, "]+$"), 'g'), '');
|
|
4097
5083
|
}
|
|
4098
|
-
return
|
|
5084
|
+
return str.replace(/\s+$/, '');
|
|
4099
5085
|
}
|
|
4100
5086
|
function split(v, arg) {
|
|
4101
|
-
var
|
|
5087
|
+
var str = stringify(v);
|
|
5088
|
+
this.context.memoryLimit.use(str.length);
|
|
5089
|
+
var arr = str.split(stringify(arg));
|
|
4102
5090
|
// align to ruby split, which is the behavior of shopify/liquid
|
|
4103
5091
|
// see: https://ruby-doc.org/core-2.4.0/String.html#method-i-split
|
|
4104
5092
|
while (arr.length && arr[arr.length - 1] === '')
|
|
@@ -4106,29 +5094,39 @@
|
|
|
4106
5094
|
return arr;
|
|
4107
5095
|
}
|
|
4108
5096
|
function strip(v, chars) {
|
|
5097
|
+
var str = stringify(v);
|
|
5098
|
+
this.context.memoryLimit.use(str.length);
|
|
4109
5099
|
if (chars) {
|
|
4110
5100
|
chars = escapeRegExp(stringify(chars));
|
|
4111
|
-
return
|
|
5101
|
+
return str
|
|
4112
5102
|
.replace(new RegExp("^[".concat(chars, "]+"), 'g'), '')
|
|
4113
5103
|
.replace(new RegExp("[".concat(chars, "]+$"), 'g'), '');
|
|
4114
5104
|
}
|
|
4115
|
-
return
|
|
5105
|
+
return str.trim();
|
|
4116
5106
|
}
|
|
4117
5107
|
function strip_newlines(v) {
|
|
4118
|
-
|
|
5108
|
+
var str = stringify(v);
|
|
5109
|
+
this.context.memoryLimit.use(str.length);
|
|
5110
|
+
return str.replace(/\r?\n/gm, '');
|
|
4119
5111
|
}
|
|
4120
5112
|
function capitalize(str) {
|
|
4121
5113
|
str = stringify(str);
|
|
5114
|
+
this.context.memoryLimit.use(str.length);
|
|
4122
5115
|
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
4123
5116
|
}
|
|
4124
5117
|
function replace(v, pattern, replacement) {
|
|
4125
|
-
|
|
5118
|
+
var str = stringify(v);
|
|
5119
|
+
this.context.memoryLimit.use(str.length);
|
|
5120
|
+
return str.split(stringify(pattern)).join(replacement);
|
|
4126
5121
|
}
|
|
4127
5122
|
function replace_first(v, arg1, arg2) {
|
|
4128
|
-
|
|
5123
|
+
var str = stringify(v);
|
|
5124
|
+
this.context.memoryLimit.use(str.length);
|
|
5125
|
+
return str.replace(stringify(arg1), arg2);
|
|
4129
5126
|
}
|
|
4130
5127
|
function replace_last(v, arg1, arg2) {
|
|
4131
5128
|
var str = stringify(v);
|
|
5129
|
+
this.context.memoryLimit.use(str.length);
|
|
4132
5130
|
var pattern = stringify(arg1);
|
|
4133
5131
|
var index = str.lastIndexOf(pattern);
|
|
4134
5132
|
if (index === -1)
|
|
@@ -4139,15 +5137,18 @@
|
|
|
4139
5137
|
function truncate(v, l, o) {
|
|
4140
5138
|
if (l === void 0) { l = 50; }
|
|
4141
5139
|
if (o === void 0) { o = '...'; }
|
|
4142
|
-
|
|
4143
|
-
|
|
5140
|
+
var str = stringify(v);
|
|
5141
|
+
this.context.memoryLimit.use(str.length);
|
|
5142
|
+
if (str.length <= l)
|
|
4144
5143
|
return v;
|
|
4145
|
-
return
|
|
5144
|
+
return str.substring(0, l - o.length) + o;
|
|
4146
5145
|
}
|
|
4147
5146
|
function truncatewords(v, words, o) {
|
|
4148
5147
|
if (words === void 0) { words = 15; }
|
|
4149
5148
|
if (o === void 0) { o = '...'; }
|
|
4150
|
-
var
|
|
5149
|
+
var str = stringify(v);
|
|
5150
|
+
this.context.memoryLimit.use(str.length);
|
|
5151
|
+
var arr = str.split(/\s+/);
|
|
4151
5152
|
if (words <= 0)
|
|
4152
5153
|
words = 1;
|
|
4153
5154
|
var ret = arr.slice(0, words).join(' ');
|
|
@@ -4156,11 +5157,14 @@
|
|
|
4156
5157
|
return ret;
|
|
4157
5158
|
}
|
|
4158
5159
|
function normalize_whitespace(v) {
|
|
4159
|
-
|
|
4160
|
-
|
|
5160
|
+
var str = stringify(v);
|
|
5161
|
+
this.context.memoryLimit.use(str.length);
|
|
5162
|
+
return str.replace(/\s+/g, ' ');
|
|
4161
5163
|
}
|
|
4162
5164
|
function number_of_words(input, mode) {
|
|
4163
|
-
|
|
5165
|
+
var str = stringify(input);
|
|
5166
|
+
this.context.memoryLimit.use(str.length);
|
|
5167
|
+
input = str.trim();
|
|
4164
5168
|
if (!input)
|
|
4165
5169
|
return 0;
|
|
4166
5170
|
switch (mode) {
|
|
@@ -4179,6 +5183,7 @@
|
|
|
4179
5183
|
}
|
|
4180
5184
|
function array_to_sentence_string(array, connector) {
|
|
4181
5185
|
if (connector === void 0) { connector = 'and'; }
|
|
5186
|
+
this.context.memoryLimit.use(array.length);
|
|
4182
5187
|
switch (array.length) {
|
|
4183
5188
|
case 0:
|
|
4184
5189
|
return '';
|
|
@@ -4222,7 +5227,8 @@
|
|
|
4222
5227
|
__extends(default_1, _super);
|
|
4223
5228
|
function default_1(token, remainTokens, liquid) {
|
|
4224
5229
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4225
|
-
_this.
|
|
5230
|
+
_this.identifier = _this.tokenizer.readIdentifier();
|
|
5231
|
+
_this.key = _this.identifier.content;
|
|
4226
5232
|
_this.tokenizer.assert(_this.key, 'expected variable name');
|
|
4227
5233
|
_this.tokenizer.skipBlank();
|
|
4228
5234
|
_this.tokenizer.assert(_this.tokenizer.peek() === '=', 'expected "="');
|
|
@@ -4244,13 +5250,33 @@
|
|
|
4244
5250
|
}
|
|
4245
5251
|
});
|
|
4246
5252
|
};
|
|
5253
|
+
default_1.prototype.arguments = function () {
|
|
5254
|
+
return __generator(this, function (_a) {
|
|
5255
|
+
switch (_a.label) {
|
|
5256
|
+
case 0: return [4 /*yield*/, this.value];
|
|
5257
|
+
case 1:
|
|
5258
|
+
_a.sent();
|
|
5259
|
+
return [2 /*return*/];
|
|
5260
|
+
}
|
|
5261
|
+
});
|
|
5262
|
+
};
|
|
5263
|
+
default_1.prototype.localScope = function () {
|
|
5264
|
+
return __generator(this, function (_a) {
|
|
5265
|
+
switch (_a.label) {
|
|
5266
|
+
case 0: return [4 /*yield*/, this.identifier];
|
|
5267
|
+
case 1:
|
|
5268
|
+
_a.sent();
|
|
5269
|
+
return [2 /*return*/];
|
|
5270
|
+
}
|
|
5271
|
+
});
|
|
5272
|
+
};
|
|
4247
5273
|
return default_1;
|
|
4248
5274
|
}(Tag));
|
|
4249
5275
|
|
|
4250
5276
|
var MODIFIERS = ['offset', 'limit', 'reversed'];
|
|
4251
5277
|
var default_1$1 = /** @class */ (function (_super) {
|
|
4252
5278
|
__extends(default_1, _super);
|
|
4253
|
-
function default_1(token, remainTokens, liquid) {
|
|
5279
|
+
function default_1(token, remainTokens, liquid, parser) {
|
|
4254
5280
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4255
5281
|
var variable = _this.tokenizer.readIdentifier();
|
|
4256
5282
|
var inStr = _this.tokenizer.readIdentifier();
|
|
@@ -4260,18 +5286,16 @@
|
|
|
4260
5286
|
}
|
|
4261
5287
|
_this.variable = variable.content;
|
|
4262
5288
|
_this.collection = collection;
|
|
4263
|
-
_this.hash = new Hash(_this.tokenizer.
|
|
5289
|
+
_this.hash = new Hash(_this.tokenizer, liquid.options.keyValueSeparator);
|
|
4264
5290
|
_this.templates = [];
|
|
4265
5291
|
_this.elseTemplates = [];
|
|
4266
5292
|
var p;
|
|
4267
|
-
var stream =
|
|
5293
|
+
var stream = parser.parseStream(remainTokens)
|
|
4268
5294
|
.on('start', function () { return (p = _this.templates); })
|
|
4269
|
-
.on('tag:else', function () {
|
|
4270
|
-
.on('tag:endfor', function () {
|
|
5295
|
+
.on('tag:else', function (tag) { assertEmpty(tag.args); p = _this.elseTemplates; })
|
|
5296
|
+
.on('tag:endfor', function (tag) { assertEmpty(tag.args); stream.stop(); })
|
|
4271
5297
|
.on('template', function (tpl) { return p.push(tpl); })
|
|
4272
|
-
.on('end', function () {
|
|
4273
|
-
throw new Error("tag ".concat(token.getText(), " not closed"));
|
|
4274
|
-
});
|
|
5298
|
+
.on('end', function () { throw new Error("tag ".concat(token.getText(), " not closed")); });
|
|
4275
5299
|
stream.start();
|
|
4276
5300
|
return _this;
|
|
4277
5301
|
}
|
|
@@ -4320,14 +5344,12 @@
|
|
|
4320
5344
|
if (!!collection_1_1.done) return [3 /*break*/, 9];
|
|
4321
5345
|
item = collection_1_1.value;
|
|
4322
5346
|
scope[this.variable] = item;
|
|
5347
|
+
ctx.continueCalled = ctx.breakCalled = false;
|
|
4323
5348
|
return [4 /*yield*/, r.renderTemplates(this.templates, ctx, emitter)];
|
|
4324
5349
|
case 7:
|
|
4325
5350
|
_c.sent();
|
|
4326
|
-
if (
|
|
4327
|
-
emitter['break'] = false;
|
|
5351
|
+
if (ctx.breakCalled)
|
|
4328
5352
|
return [3 /*break*/, 9];
|
|
4329
|
-
}
|
|
4330
|
-
emitter['continue'] = false;
|
|
4331
5353
|
scope.forloop.next();
|
|
4332
5354
|
_c.label = 8;
|
|
4333
5355
|
case 8:
|
|
@@ -4345,11 +5367,64 @@
|
|
|
4345
5367
|
finally { if (e_1) throw e_1.error; }
|
|
4346
5368
|
return [7 /*endfinally*/];
|
|
4347
5369
|
case 12:
|
|
5370
|
+
ctx.continueCalled = ctx.breakCalled = false;
|
|
4348
5371
|
ctx.pop();
|
|
4349
5372
|
return [2 /*return*/];
|
|
4350
5373
|
}
|
|
4351
5374
|
});
|
|
4352
5375
|
};
|
|
5376
|
+
default_1.prototype.children = function () {
|
|
5377
|
+
var templates;
|
|
5378
|
+
return __generator(this, function (_a) {
|
|
5379
|
+
templates = this.templates.slice();
|
|
5380
|
+
if (this.elseTemplates) {
|
|
5381
|
+
templates.push.apply(templates, __spreadArray([], __read(this.elseTemplates), false));
|
|
5382
|
+
}
|
|
5383
|
+
return [2 /*return*/, templates];
|
|
5384
|
+
});
|
|
5385
|
+
};
|
|
5386
|
+
default_1.prototype.arguments = function () {
|
|
5387
|
+
var _a, _b, v, e_2_1;
|
|
5388
|
+
var e_2, _c;
|
|
5389
|
+
return __generator(this, function (_d) {
|
|
5390
|
+
switch (_d.label) {
|
|
5391
|
+
case 0: return [4 /*yield*/, this.collection];
|
|
5392
|
+
case 1:
|
|
5393
|
+
_d.sent();
|
|
5394
|
+
_d.label = 2;
|
|
5395
|
+
case 2:
|
|
5396
|
+
_d.trys.push([2, 7, 8, 9]);
|
|
5397
|
+
_a = __values(Object.values(this.hash.hash)), _b = _a.next();
|
|
5398
|
+
_d.label = 3;
|
|
5399
|
+
case 3:
|
|
5400
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
5401
|
+
v = _b.value;
|
|
5402
|
+
if (!isValueToken(v)) return [3 /*break*/, 5];
|
|
5403
|
+
return [4 /*yield*/, v];
|
|
5404
|
+
case 4:
|
|
5405
|
+
_d.sent();
|
|
5406
|
+
_d.label = 5;
|
|
5407
|
+
case 5:
|
|
5408
|
+
_b = _a.next();
|
|
5409
|
+
return [3 /*break*/, 3];
|
|
5410
|
+
case 6: return [3 /*break*/, 9];
|
|
5411
|
+
case 7:
|
|
5412
|
+
e_2_1 = _d.sent();
|
|
5413
|
+
e_2 = { error: e_2_1 };
|
|
5414
|
+
return [3 /*break*/, 9];
|
|
5415
|
+
case 8:
|
|
5416
|
+
try {
|
|
5417
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
5418
|
+
}
|
|
5419
|
+
finally { if (e_2) throw e_2.error; }
|
|
5420
|
+
return [7 /*endfinally*/];
|
|
5421
|
+
case 9: return [2 /*return*/];
|
|
5422
|
+
}
|
|
5423
|
+
});
|
|
5424
|
+
};
|
|
5425
|
+
default_1.prototype.blockScope = function () {
|
|
5426
|
+
return [this.variable, 'forloop'];
|
|
5427
|
+
};
|
|
4353
5428
|
return default_1;
|
|
4354
5429
|
}(Tag));
|
|
4355
5430
|
function reversed(arr) {
|
|
@@ -4364,18 +5439,28 @@
|
|
|
4364
5439
|
|
|
4365
5440
|
var default_1$2 = /** @class */ (function (_super) {
|
|
4366
5441
|
__extends(default_1, _super);
|
|
4367
|
-
function default_1(tagToken, remainTokens, liquid) {
|
|
5442
|
+
function default_1(tagToken, remainTokens, liquid, parser) {
|
|
4368
5443
|
var _this = _super.call(this, tagToken, remainTokens, liquid) || this;
|
|
4369
5444
|
_this.templates = [];
|
|
4370
|
-
_this.
|
|
5445
|
+
_this.identifier = _this.readVariable();
|
|
5446
|
+
_this.variable = _this.identifier.content;
|
|
4371
5447
|
while (remainTokens.length) {
|
|
4372
5448
|
var token = remainTokens.shift();
|
|
4373
5449
|
if (isTagToken(token) && token.name === 'endcapture')
|
|
4374
5450
|
return _this;
|
|
4375
|
-
_this.templates.push(
|
|
5451
|
+
_this.templates.push(parser.parseToken(token, remainTokens));
|
|
4376
5452
|
}
|
|
4377
5453
|
throw new Error("tag ".concat(tagToken.getText(), " not closed"));
|
|
4378
5454
|
}
|
|
5455
|
+
default_1.prototype.readVariable = function () {
|
|
5456
|
+
var ident = this.tokenizer.readIdentifier();
|
|
5457
|
+
if (ident.content)
|
|
5458
|
+
return ident;
|
|
5459
|
+
ident = this.tokenizer.readQuoted();
|
|
5460
|
+
if (ident)
|
|
5461
|
+
return ident;
|
|
5462
|
+
throw this.tokenizer.error('invalid capture name');
|
|
5463
|
+
};
|
|
4379
5464
|
default_1.prototype.render = function (ctx) {
|
|
4380
5465
|
var r, html;
|
|
4381
5466
|
return __generator(this, function (_a) {
|
|
@@ -4390,21 +5475,27 @@
|
|
|
4390
5475
|
}
|
|
4391
5476
|
});
|
|
4392
5477
|
};
|
|
4393
|
-
default_1.prototype.
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
5478
|
+
default_1.prototype.children = function () {
|
|
5479
|
+
return __generator(this, function (_a) {
|
|
5480
|
+
return [2 /*return*/, this.templates];
|
|
5481
|
+
});
|
|
5482
|
+
};
|
|
5483
|
+
default_1.prototype.localScope = function () {
|
|
5484
|
+
return __generator(this, function (_a) {
|
|
5485
|
+
switch (_a.label) {
|
|
5486
|
+
case 0: return [4 /*yield*/, this.identifier];
|
|
5487
|
+
case 1:
|
|
5488
|
+
_a.sent();
|
|
5489
|
+
return [2 /*return*/];
|
|
5490
|
+
}
|
|
5491
|
+
});
|
|
4401
5492
|
};
|
|
4402
5493
|
return default_1;
|
|
4403
5494
|
}(Tag));
|
|
4404
5495
|
|
|
4405
5496
|
var default_1$3 = /** @class */ (function (_super) {
|
|
4406
5497
|
__extends(default_1, _super);
|
|
4407
|
-
function default_1(tagToken, remainTokens, liquid) {
|
|
5498
|
+
function default_1(tagToken, remainTokens, liquid, parser) {
|
|
4408
5499
|
var _this = _super.call(this, tagToken, remainTokens, liquid) || this;
|
|
4409
5500
|
_this.branches = [];
|
|
4410
5501
|
_this.elseTemplates = [];
|
|
@@ -4412,7 +5503,7 @@
|
|
|
4412
5503
|
_this.elseTemplates = [];
|
|
4413
5504
|
var p = [];
|
|
4414
5505
|
var elseCount = 0;
|
|
4415
|
-
var stream =
|
|
5506
|
+
var stream = parser.parseStream(remainTokens)
|
|
4416
5507
|
.on('tag:when', function (token) {
|
|
4417
5508
|
if (elseCount > 0) {
|
|
4418
5509
|
return;
|
|
@@ -4525,6 +5616,29 @@
|
|
|
4525
5616
|
}
|
|
4526
5617
|
});
|
|
4527
5618
|
};
|
|
5619
|
+
default_1.prototype.arguments = function () {
|
|
5620
|
+
return __generator(this, function (_a) {
|
|
5621
|
+
switch (_a.label) {
|
|
5622
|
+
case 0: return [4 /*yield*/, this.value];
|
|
5623
|
+
case 1:
|
|
5624
|
+
_a.sent();
|
|
5625
|
+
return [5 /*yield**/, __values(this.branches.flatMap(function (b) { return b.values; }))];
|
|
5626
|
+
case 2:
|
|
5627
|
+
_a.sent();
|
|
5628
|
+
return [2 /*return*/];
|
|
5629
|
+
}
|
|
5630
|
+
});
|
|
5631
|
+
};
|
|
5632
|
+
default_1.prototype.children = function () {
|
|
5633
|
+
var templates;
|
|
5634
|
+
return __generator(this, function (_a) {
|
|
5635
|
+
templates = this.branches.flatMap(function (b) { return b.templates; });
|
|
5636
|
+
if (this.elseTemplates) {
|
|
5637
|
+
templates.push.apply(templates, __spreadArray([], __read(this.elseTemplates), false));
|
|
5638
|
+
}
|
|
5639
|
+
return [2 /*return*/, templates];
|
|
5640
|
+
});
|
|
5641
|
+
};
|
|
4528
5642
|
return default_1;
|
|
4529
5643
|
}(Tag));
|
|
4530
5644
|
|
|
@@ -4545,10 +5659,10 @@
|
|
|
4545
5659
|
|
|
4546
5660
|
var default_1$5 = /** @class */ (function (_super) {
|
|
4547
5661
|
__extends(default_1, _super);
|
|
4548
|
-
function default_1(token, remainTokens, liquid) {
|
|
5662
|
+
function default_1(token, remainTokens, liquid, parser) {
|
|
4549
5663
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4550
5664
|
var tokenizer = _this.tokenizer;
|
|
4551
|
-
_this.file = parseFilePath(tokenizer, _this.liquid);
|
|
5665
|
+
_this.file = parseFilePath(tokenizer, _this.liquid, parser);
|
|
4552
5666
|
_this.currentFile = token.file;
|
|
4553
5667
|
while (!tokenizer.end()) {
|
|
4554
5668
|
tokenizer.skipBlank();
|
|
@@ -4582,7 +5696,7 @@
|
|
|
4582
5696
|
tokenizer.p = begin;
|
|
4583
5697
|
break;
|
|
4584
5698
|
}
|
|
4585
|
-
_this.hash = new Hash(tokenizer.
|
|
5699
|
+
_this.hash = new Hash(tokenizer, liquid.options.keyValueSeparator);
|
|
4586
5700
|
return _this;
|
|
4587
5701
|
}
|
|
4588
5702
|
default_1.prototype.render = function (ctx, emitter) {
|
|
@@ -4596,7 +5710,7 @@
|
|
|
4596
5710
|
case 1:
|
|
4597
5711
|
filepath = (_k.sent());
|
|
4598
5712
|
assert(filepath, function () { return "illegal file path \"".concat(filepath, "\""); });
|
|
4599
|
-
childCtx =
|
|
5713
|
+
childCtx = ctx.spawn();
|
|
4600
5714
|
scope = childCtx.bottom();
|
|
4601
5715
|
_b = __assign;
|
|
4602
5716
|
_c = [scope];
|
|
@@ -4662,6 +5776,92 @@
|
|
|
4662
5776
|
}
|
|
4663
5777
|
});
|
|
4664
5778
|
};
|
|
5779
|
+
default_1.prototype.children = function (partials, sync) {
|
|
5780
|
+
return __generator(this, function (_a) {
|
|
5781
|
+
switch (_a.label) {
|
|
5782
|
+
case 0:
|
|
5783
|
+
if (!(partials && isString(this['file']))) return [3 /*break*/, 2];
|
|
5784
|
+
return [4 /*yield*/, this.liquid._parsePartialFile(this['file'], sync, this['currentFile'])];
|
|
5785
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
5786
|
+
case 2: return [2 /*return*/, []];
|
|
5787
|
+
}
|
|
5788
|
+
});
|
|
5789
|
+
};
|
|
5790
|
+
default_1.prototype.partialScope = function () {
|
|
5791
|
+
if (isString(this['file'])) {
|
|
5792
|
+
var names = Object.keys(this.hash.hash);
|
|
5793
|
+
if (this['with']) {
|
|
5794
|
+
var _a = this['with'], value = _a.value, alias = _a.alias;
|
|
5795
|
+
if (isString(alias)) {
|
|
5796
|
+
names.push([alias, value]);
|
|
5797
|
+
}
|
|
5798
|
+
else if (isString(this.file)) {
|
|
5799
|
+
names.push([this.file, value]);
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
if (this['for']) {
|
|
5803
|
+
var _b = this['for'], value = _b.value, alias = _b.alias;
|
|
5804
|
+
if (isString(alias)) {
|
|
5805
|
+
names.push([alias, value]);
|
|
5806
|
+
}
|
|
5807
|
+
else if (isString(this.file)) {
|
|
5808
|
+
names.push([this.file, value]);
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
return { name: this['file'], isolated: true, scope: names };
|
|
5812
|
+
}
|
|
5813
|
+
};
|
|
5814
|
+
default_1.prototype.arguments = function () {
|
|
5815
|
+
var _a, _b, v, e_2_1, value, value;
|
|
5816
|
+
var e_2, _c;
|
|
5817
|
+
return __generator(this, function (_d) {
|
|
5818
|
+
switch (_d.label) {
|
|
5819
|
+
case 0:
|
|
5820
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
5821
|
+
_a = __values(Object.values(this.hash.hash)), _b = _a.next();
|
|
5822
|
+
_d.label = 1;
|
|
5823
|
+
case 1:
|
|
5824
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
5825
|
+
v = _b.value;
|
|
5826
|
+
if (!isValueToken(v)) return [3 /*break*/, 3];
|
|
5827
|
+
return [4 /*yield*/, v];
|
|
5828
|
+
case 2:
|
|
5829
|
+
_d.sent();
|
|
5830
|
+
_d.label = 3;
|
|
5831
|
+
case 3:
|
|
5832
|
+
_b = _a.next();
|
|
5833
|
+
return [3 /*break*/, 1];
|
|
5834
|
+
case 4: return [3 /*break*/, 7];
|
|
5835
|
+
case 5:
|
|
5836
|
+
e_2_1 = _d.sent();
|
|
5837
|
+
e_2 = { error: e_2_1 };
|
|
5838
|
+
return [3 /*break*/, 7];
|
|
5839
|
+
case 6:
|
|
5840
|
+
try {
|
|
5841
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
5842
|
+
}
|
|
5843
|
+
finally { if (e_2) throw e_2.error; }
|
|
5844
|
+
return [7 /*endfinally*/];
|
|
5845
|
+
case 7:
|
|
5846
|
+
if (!this['with']) return [3 /*break*/, 9];
|
|
5847
|
+
value = this['with'].value;
|
|
5848
|
+
if (!isValueToken(value)) return [3 /*break*/, 9];
|
|
5849
|
+
return [4 /*yield*/, value];
|
|
5850
|
+
case 8:
|
|
5851
|
+
_d.sent();
|
|
5852
|
+
_d.label = 9;
|
|
5853
|
+
case 9:
|
|
5854
|
+
if (!this['for']) return [3 /*break*/, 11];
|
|
5855
|
+
value = this['for'].value;
|
|
5856
|
+
if (!isValueToken(value)) return [3 /*break*/, 11];
|
|
5857
|
+
return [4 /*yield*/, value];
|
|
5858
|
+
case 10:
|
|
5859
|
+
_d.sent();
|
|
5860
|
+
_d.label = 11;
|
|
5861
|
+
case 11: return [2 /*return*/];
|
|
5862
|
+
}
|
|
5863
|
+
});
|
|
5864
|
+
};
|
|
4665
5865
|
return default_1;
|
|
4666
5866
|
}(Tag));
|
|
4667
5867
|
/**
|
|
@@ -4670,7 +5870,7 @@
|
|
|
4670
5870
|
* @return Token for expression (not quoted)
|
|
4671
5871
|
* @throws TypeError if cannot read next token
|
|
4672
5872
|
*/
|
|
4673
|
-
function parseFilePath(tokenizer, liquid) {
|
|
5873
|
+
function parseFilePath(tokenizer, liquid, parser) {
|
|
4674
5874
|
if (liquid.options.dynamicPartials) {
|
|
4675
5875
|
var file = tokenizer.readValue();
|
|
4676
5876
|
tokenizer.assert(file, 'illegal file path');
|
|
@@ -4678,13 +5878,13 @@
|
|
|
4678
5878
|
return;
|
|
4679
5879
|
if (isQuotedToken(file)) {
|
|
4680
5880
|
// for filenames like "files/{{file}}", eval as liquid template
|
|
4681
|
-
var templates_1 =
|
|
5881
|
+
var templates_1 = parser.parse(evalQuotedToken(file));
|
|
4682
5882
|
return optimize(templates_1);
|
|
4683
5883
|
}
|
|
4684
5884
|
return file;
|
|
4685
5885
|
}
|
|
4686
5886
|
var tokens = __spreadArray([], __read(tokenizer.readFileNameTemplate(liquid.options)), false);
|
|
4687
|
-
var templates = optimize(
|
|
5887
|
+
var templates = optimize(parser.parseTokens(tokens));
|
|
4688
5888
|
return templates === 'none' ? undefined : templates;
|
|
4689
5889
|
}
|
|
4690
5890
|
function optimize(templates) {
|
|
@@ -4709,10 +5909,10 @@
|
|
|
4709
5909
|
|
|
4710
5910
|
var default_1$6 = /** @class */ (function (_super) {
|
|
4711
5911
|
__extends(default_1, _super);
|
|
4712
|
-
function default_1(token, remainTokens, liquid) {
|
|
5912
|
+
function default_1(token, remainTokens, liquid, parser) {
|
|
4713
5913
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4714
5914
|
var tokenizer = token.tokenizer;
|
|
4715
|
-
_this['file'] = parseFilePath(tokenizer, _this.liquid);
|
|
5915
|
+
_this['file'] = parseFilePath(tokenizer, _this.liquid, parser);
|
|
4716
5916
|
_this['currentFile'] = token.file;
|
|
4717
5917
|
var begin = tokenizer.p;
|
|
4718
5918
|
var withStr = tokenizer.readIdentifier();
|
|
@@ -4726,7 +5926,7 @@
|
|
|
4726
5926
|
}
|
|
4727
5927
|
else
|
|
4728
5928
|
tokenizer.p = begin;
|
|
4729
|
-
_this.hash = new Hash(tokenizer
|
|
5929
|
+
_this.hash = new Hash(tokenizer, liquid.options.jekyllInclude || liquid.options.keyValueSeparator);
|
|
4730
5930
|
return _this;
|
|
4731
5931
|
}
|
|
4732
5932
|
default_1.prototype.render = function (ctx, emitter) {
|
|
@@ -4766,6 +5966,53 @@
|
|
|
4766
5966
|
}
|
|
4767
5967
|
});
|
|
4768
5968
|
};
|
|
5969
|
+
default_1.prototype.children = function (partials, sync) {
|
|
5970
|
+
return __generator(this, function (_a) {
|
|
5971
|
+
switch (_a.label) {
|
|
5972
|
+
case 0:
|
|
5973
|
+
if (!(partials && isString(this['file']))) return [3 /*break*/, 2];
|
|
5974
|
+
return [4 /*yield*/, this.liquid._parsePartialFile(this['file'], sync, this['currentFile'])];
|
|
5975
|
+
case 1: return [2 /*return*/, (_a.sent())];
|
|
5976
|
+
case 2: return [2 /*return*/, []];
|
|
5977
|
+
}
|
|
5978
|
+
});
|
|
5979
|
+
};
|
|
5980
|
+
default_1.prototype.partialScope = function () {
|
|
5981
|
+
if (isString(this['file'])) {
|
|
5982
|
+
var names = void 0;
|
|
5983
|
+
if (this.liquid.options.jekyllInclude) {
|
|
5984
|
+
names = ['include'];
|
|
5985
|
+
}
|
|
5986
|
+
else {
|
|
5987
|
+
names = Object.keys(this.hash.hash);
|
|
5988
|
+
if (this.withVar) {
|
|
5989
|
+
names.push([this['file'], this.withVar]);
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
return { name: this['file'], isolated: false, scope: names };
|
|
5993
|
+
}
|
|
5994
|
+
};
|
|
5995
|
+
default_1.prototype.arguments = function () {
|
|
5996
|
+
return __generator(this, function (_a) {
|
|
5997
|
+
switch (_a.label) {
|
|
5998
|
+
case 0: return [5 /*yield**/, __values(Object.values(this.hash.hash).filter(isValueToken))];
|
|
5999
|
+
case 1:
|
|
6000
|
+
_a.sent();
|
|
6001
|
+
if (!isValueToken(this['file'])) return [3 /*break*/, 3];
|
|
6002
|
+
return [4 /*yield*/, this['file']];
|
|
6003
|
+
case 2:
|
|
6004
|
+
_a.sent();
|
|
6005
|
+
_a.label = 3;
|
|
6006
|
+
case 3:
|
|
6007
|
+
if (!isValueToken(this.withVar)) return [3 /*break*/, 5];
|
|
6008
|
+
return [4 /*yield*/, this.withVar];
|
|
6009
|
+
case 4:
|
|
6010
|
+
_a.sent();
|
|
6011
|
+
_a.label = 5;
|
|
6012
|
+
case 5: return [2 /*return*/];
|
|
6013
|
+
}
|
|
6014
|
+
});
|
|
6015
|
+
};
|
|
4769
6016
|
return default_1;
|
|
4770
6017
|
}(Tag));
|
|
4771
6018
|
|
|
@@ -4773,7 +6020,8 @@
|
|
|
4773
6020
|
__extends(default_1, _super);
|
|
4774
6021
|
function default_1(token, remainTokens, liquid) {
|
|
4775
6022
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4776
|
-
_this.
|
|
6023
|
+
_this.identifier = _this.tokenizer.readIdentifier();
|
|
6024
|
+
_this.variable = _this.identifier.content;
|
|
4777
6025
|
return _this;
|
|
4778
6026
|
}
|
|
4779
6027
|
default_1.prototype.render = function (context, emitter) {
|
|
@@ -4783,6 +6031,16 @@
|
|
|
4783
6031
|
}
|
|
4784
6032
|
emitter.write(stringify(--scope[this.variable]));
|
|
4785
6033
|
};
|
|
6034
|
+
default_1.prototype.localScope = function () {
|
|
6035
|
+
return __generator(this, function (_a) {
|
|
6036
|
+
switch (_a.label) {
|
|
6037
|
+
case 0: return [4 /*yield*/, this.identifier];
|
|
6038
|
+
case 1:
|
|
6039
|
+
_a.sent();
|
|
6040
|
+
return [2 /*return*/];
|
|
6041
|
+
}
|
|
6042
|
+
});
|
|
6043
|
+
};
|
|
4786
6044
|
return default_1;
|
|
4787
6045
|
}(Tag));
|
|
4788
6046
|
|
|
@@ -4831,42 +6089,49 @@
|
|
|
4831
6089
|
}
|
|
4832
6090
|
});
|
|
4833
6091
|
};
|
|
6092
|
+
default_1.prototype.arguments = function () {
|
|
6093
|
+
return __generator(this, function (_a) {
|
|
6094
|
+
switch (_a.label) {
|
|
6095
|
+
case 0: return [5 /*yield**/, __values(this.candidates)];
|
|
6096
|
+
case 1:
|
|
6097
|
+
_a.sent();
|
|
6098
|
+
if (!this.group) return [3 /*break*/, 3];
|
|
6099
|
+
return [4 /*yield*/, this.group];
|
|
6100
|
+
case 2:
|
|
6101
|
+
_a.sent();
|
|
6102
|
+
_a.label = 3;
|
|
6103
|
+
case 3: return [2 /*return*/];
|
|
6104
|
+
}
|
|
6105
|
+
});
|
|
6106
|
+
};
|
|
4834
6107
|
return default_1;
|
|
4835
6108
|
}(Tag));
|
|
4836
6109
|
|
|
4837
6110
|
var default_1$9 = /** @class */ (function (_super) {
|
|
4838
6111
|
__extends(default_1, _super);
|
|
4839
|
-
function default_1(tagToken, remainTokens, liquid) {
|
|
6112
|
+
function default_1(tagToken, remainTokens, liquid, parser) {
|
|
4840
6113
|
var _this = _super.call(this, tagToken, remainTokens, liquid) || this;
|
|
4841
6114
|
_this.branches = [];
|
|
4842
|
-
_this.elseTemplates = [];
|
|
4843
6115
|
var p = [];
|
|
4844
|
-
|
|
4845
|
-
liquid.parser.parseStream(remainTokens)
|
|
6116
|
+
parser.parseStream(remainTokens)
|
|
4846
6117
|
.on('start', function () { return _this.branches.push({
|
|
4847
|
-
value: new Value(tagToken.
|
|
6118
|
+
value: new Value(tagToken.tokenizer.readFilteredValue(), _this.liquid),
|
|
4848
6119
|
templates: (p = [])
|
|
4849
6120
|
}); })
|
|
4850
6121
|
.on('tag:elsif', function (token) {
|
|
4851
|
-
|
|
4852
|
-
p = [];
|
|
4853
|
-
return;
|
|
4854
|
-
}
|
|
6122
|
+
assert(!_this.elseTemplates, 'unexpected elsif after else');
|
|
4855
6123
|
_this.branches.push({
|
|
4856
|
-
value: new Value(token.
|
|
6124
|
+
value: new Value(token.tokenizer.readFilteredValue(), _this.liquid),
|
|
4857
6125
|
templates: (p = [])
|
|
4858
6126
|
});
|
|
4859
6127
|
})
|
|
4860
|
-
.on('tag:else', function () {
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
.on('tag:endif', function () { this.stop(); })
|
|
4865
|
-
.on('template', function (tpl) {
|
|
4866
|
-
if (p !== _this.elseTemplates || elseCount === 1) {
|
|
4867
|
-
p.push(tpl);
|
|
4868
|
-
}
|
|
6128
|
+
.on('tag:else', function (tag) {
|
|
6129
|
+
assertEmpty(tag.args);
|
|
6130
|
+
assert(!_this.elseTemplates, 'duplicated else');
|
|
6131
|
+
p = _this.elseTemplates = [];
|
|
4869
6132
|
})
|
|
6133
|
+
.on('tag:endif', function (tag) { assertEmpty(tag.args); this.stop(); })
|
|
6134
|
+
.on('template', function (tpl) { return p.push(tpl); })
|
|
4870
6135
|
.on('end', function () { throw new Error("tag ".concat(tagToken.getText(), " not closed")); })
|
|
4871
6136
|
.start();
|
|
4872
6137
|
return _this;
|
|
@@ -4908,13 +6173,26 @@
|
|
|
4908
6173
|
}
|
|
4909
6174
|
finally { if (e_1) throw e_1.error; }
|
|
4910
6175
|
return [7 /*endfinally*/];
|
|
4911
|
-
case 9: return [4 /*yield*/, r.renderTemplates(this.elseTemplates, ctx, emitter)];
|
|
6176
|
+
case 9: return [4 /*yield*/, r.renderTemplates(this.elseTemplates || [], ctx, emitter)];
|
|
4912
6177
|
case 10:
|
|
4913
6178
|
_e.sent();
|
|
4914
6179
|
return [2 /*return*/];
|
|
4915
6180
|
}
|
|
4916
6181
|
});
|
|
4917
6182
|
};
|
|
6183
|
+
default_1.prototype.children = function () {
|
|
6184
|
+
var templates;
|
|
6185
|
+
return __generator(this, function (_a) {
|
|
6186
|
+
templates = this.branches.flatMap(function (b) { return b.templates; });
|
|
6187
|
+
if (this.elseTemplates) {
|
|
6188
|
+
templates.push.apply(templates, __spreadArray([], __read(this.elseTemplates), false));
|
|
6189
|
+
}
|
|
6190
|
+
return [2 /*return*/, templates];
|
|
6191
|
+
});
|
|
6192
|
+
};
|
|
6193
|
+
default_1.prototype.arguments = function () {
|
|
6194
|
+
return this.branches.map(function (b) { return b.value; });
|
|
6195
|
+
};
|
|
4918
6196
|
return default_1;
|
|
4919
6197
|
}(Tag));
|
|
4920
6198
|
|
|
@@ -4922,7 +6200,8 @@
|
|
|
4922
6200
|
__extends(default_1, _super);
|
|
4923
6201
|
function default_1(token, remainTokens, liquid) {
|
|
4924
6202
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4925
|
-
_this.
|
|
6203
|
+
_this.identifier = _this.tokenizer.readIdentifier();
|
|
6204
|
+
_this.variable = _this.identifier.content;
|
|
4926
6205
|
return _this;
|
|
4927
6206
|
}
|
|
4928
6207
|
default_1.prototype.render = function (context, emitter) {
|
|
@@ -4934,17 +6213,27 @@
|
|
|
4934
6213
|
scope[this.variable]++;
|
|
4935
6214
|
emitter.write(stringify(val));
|
|
4936
6215
|
};
|
|
6216
|
+
default_1.prototype.localScope = function () {
|
|
6217
|
+
return __generator(this, function (_a) {
|
|
6218
|
+
switch (_a.label) {
|
|
6219
|
+
case 0: return [4 /*yield*/, this.identifier];
|
|
6220
|
+
case 1:
|
|
6221
|
+
_a.sent();
|
|
6222
|
+
return [2 /*return*/];
|
|
6223
|
+
}
|
|
6224
|
+
});
|
|
6225
|
+
};
|
|
4937
6226
|
return default_1;
|
|
4938
6227
|
}(Tag));
|
|
4939
6228
|
|
|
4940
6229
|
var default_1$b = /** @class */ (function (_super) {
|
|
4941
6230
|
__extends(default_1, _super);
|
|
4942
|
-
function default_1(token, remainTokens, liquid) {
|
|
6231
|
+
function default_1(token, remainTokens, liquid, parser) {
|
|
4943
6232
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
4944
|
-
_this.file = parseFilePath(_this.tokenizer, _this.liquid);
|
|
6233
|
+
_this.file = parseFilePath(_this.tokenizer, _this.liquid, parser);
|
|
4945
6234
|
_this['currentFile'] = token.file;
|
|
4946
|
-
_this.args = new Hash(_this.tokenizer.
|
|
4947
|
-
_this.templates =
|
|
6235
|
+
_this.args = new Hash(_this.tokenizer, liquid.options.keyValueSeparator);
|
|
6236
|
+
_this.templates = parser.parseTokens(remainTokens);
|
|
4948
6237
|
return _this;
|
|
4949
6238
|
}
|
|
4950
6239
|
default_1.prototype.render = function (ctx, emitter) {
|
|
@@ -4991,12 +6280,76 @@
|
|
|
4991
6280
|
}
|
|
4992
6281
|
});
|
|
4993
6282
|
};
|
|
6283
|
+
default_1.prototype.children = function (partials) {
|
|
6284
|
+
var templates, _a, _b, _c, _d;
|
|
6285
|
+
return __generator(this, function (_e) {
|
|
6286
|
+
switch (_e.label) {
|
|
6287
|
+
case 0:
|
|
6288
|
+
templates = this.templates.slice();
|
|
6289
|
+
if (!(partials && isString(this.file))) return [3 /*break*/, 2];
|
|
6290
|
+
_b = (_a = templates.push).apply;
|
|
6291
|
+
_c = [templates];
|
|
6292
|
+
_d = [[]];
|
|
6293
|
+
return [4 /*yield*/, this.liquid._parsePartialFile(this.file, true, this['currentFile'])];
|
|
6294
|
+
case 1:
|
|
6295
|
+
_b.apply(_a, _c.concat([__spreadArray.apply(void 0, _d.concat([__read.apply(void 0, [(_e.sent())]), false]))]));
|
|
6296
|
+
_e.label = 2;
|
|
6297
|
+
case 2: return [2 /*return*/, templates];
|
|
6298
|
+
}
|
|
6299
|
+
});
|
|
6300
|
+
};
|
|
6301
|
+
default_1.prototype.arguments = function () {
|
|
6302
|
+
var _a, _b, v, e_1_1;
|
|
6303
|
+
var e_1, _c;
|
|
6304
|
+
return __generator(this, function (_d) {
|
|
6305
|
+
switch (_d.label) {
|
|
6306
|
+
case 0:
|
|
6307
|
+
_d.trys.push([0, 5, 6, 7]);
|
|
6308
|
+
_a = __values(Object.values(this.args.hash)), _b = _a.next();
|
|
6309
|
+
_d.label = 1;
|
|
6310
|
+
case 1:
|
|
6311
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
6312
|
+
v = _b.value;
|
|
6313
|
+
if (!isValueToken(v)) return [3 /*break*/, 3];
|
|
6314
|
+
return [4 /*yield*/, v];
|
|
6315
|
+
case 2:
|
|
6316
|
+
_d.sent();
|
|
6317
|
+
_d.label = 3;
|
|
6318
|
+
case 3:
|
|
6319
|
+
_b = _a.next();
|
|
6320
|
+
return [3 /*break*/, 1];
|
|
6321
|
+
case 4: return [3 /*break*/, 7];
|
|
6322
|
+
case 5:
|
|
6323
|
+
e_1_1 = _d.sent();
|
|
6324
|
+
e_1 = { error: e_1_1 };
|
|
6325
|
+
return [3 /*break*/, 7];
|
|
6326
|
+
case 6:
|
|
6327
|
+
try {
|
|
6328
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
6329
|
+
}
|
|
6330
|
+
finally { if (e_1) throw e_1.error; }
|
|
6331
|
+
return [7 /*endfinally*/];
|
|
6332
|
+
case 7:
|
|
6333
|
+
if (!isValueToken(this.file)) return [3 /*break*/, 9];
|
|
6334
|
+
return [4 /*yield*/, this.file];
|
|
6335
|
+
case 8:
|
|
6336
|
+
_d.sent();
|
|
6337
|
+
_d.label = 9;
|
|
6338
|
+
case 9: return [2 /*return*/];
|
|
6339
|
+
}
|
|
6340
|
+
});
|
|
6341
|
+
};
|
|
6342
|
+
default_1.prototype.partialScope = function () {
|
|
6343
|
+
if (isString(this.file)) {
|
|
6344
|
+
return { name: this.file, isolated: false, scope: Object.keys(this.args.hash) };
|
|
6345
|
+
}
|
|
6346
|
+
};
|
|
4994
6347
|
return default_1;
|
|
4995
6348
|
}(Tag));
|
|
4996
6349
|
|
|
4997
6350
|
var default_1$c = /** @class */ (function (_super) {
|
|
4998
6351
|
__extends(default_1, _super);
|
|
4999
|
-
function default_1(token, remainTokens, liquid) {
|
|
6352
|
+
function default_1(token, remainTokens, liquid, parser) {
|
|
5000
6353
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
5001
6354
|
_this.templates = [];
|
|
5002
6355
|
var match = /\w+/.exec(token.args);
|
|
@@ -5005,7 +6358,7 @@
|
|
|
5005
6358
|
var token_1 = remainTokens.shift();
|
|
5006
6359
|
if (isTagToken(token_1) && token_1.name === 'endblock')
|
|
5007
6360
|
return _this;
|
|
5008
|
-
var template =
|
|
6361
|
+
var template = parser.parseToken(token_1, remainTokens);
|
|
5009
6362
|
_this.templates.push(template);
|
|
5010
6363
|
}
|
|
5011
6364
|
throw new Error("tag ".concat(token.getText(), " not closed"));
|
|
@@ -5048,6 +6401,14 @@
|
|
|
5048
6401
|
? function (superBlock, emitter) { return renderChild(new BlockDrop(function () { return renderCurrent(superBlock, emitter); }), emitter); }
|
|
5049
6402
|
: renderCurrent;
|
|
5050
6403
|
};
|
|
6404
|
+
default_1.prototype.children = function () {
|
|
6405
|
+
return __generator(this, function (_a) {
|
|
6406
|
+
return [2 /*return*/, this.templates];
|
|
6407
|
+
});
|
|
6408
|
+
};
|
|
6409
|
+
default_1.prototype.blockScope = function () {
|
|
6410
|
+
return ['block'];
|
|
6411
|
+
};
|
|
5051
6412
|
return default_1;
|
|
5052
6413
|
}(Tag));
|
|
5053
6414
|
|
|
@@ -5098,7 +6459,7 @@
|
|
|
5098
6459
|
|
|
5099
6460
|
var default_1$e = /** @class */ (function (_super) {
|
|
5100
6461
|
__extends(default_1, _super);
|
|
5101
|
-
function default_1(tagToken, remainTokens, liquid) {
|
|
6462
|
+
function default_1(tagToken, remainTokens, liquid, parser) {
|
|
5102
6463
|
var _this = _super.call(this, tagToken, remainTokens, liquid) || this;
|
|
5103
6464
|
var variable = _this.tokenizer.readIdentifier();
|
|
5104
6465
|
_this.tokenizer.skipBlank();
|
|
@@ -5109,10 +6470,10 @@
|
|
|
5109
6470
|
}
|
|
5110
6471
|
_this.variable = variable.content;
|
|
5111
6472
|
_this.collection = collectionToken;
|
|
5112
|
-
_this.args = new Hash(_this.tokenizer.
|
|
6473
|
+
_this.args = new Hash(_this.tokenizer, liquid.options.keyValueSeparator);
|
|
5113
6474
|
_this.templates = [];
|
|
5114
6475
|
var p;
|
|
5115
|
-
var stream =
|
|
6476
|
+
var stream = parser.parseStream(remainTokens)
|
|
5116
6477
|
.on('start', function () { return (p = _this.templates); })
|
|
5117
6478
|
.on('tag:endtablerow', function () { return stream.stop(); })
|
|
5118
6479
|
.on('template', function (tpl) { return p.push(tpl); })
|
|
@@ -5169,20 +6530,67 @@
|
|
|
5169
6530
|
}
|
|
5170
6531
|
});
|
|
5171
6532
|
};
|
|
6533
|
+
default_1.prototype.children = function () {
|
|
6534
|
+
return __generator(this, function (_a) {
|
|
6535
|
+
return [2 /*return*/, this.templates];
|
|
6536
|
+
});
|
|
6537
|
+
};
|
|
6538
|
+
default_1.prototype.arguments = function () {
|
|
6539
|
+
var _a, _b, v, e_1_1;
|
|
6540
|
+
var e_1, _c;
|
|
6541
|
+
return __generator(this, function (_d) {
|
|
6542
|
+
switch (_d.label) {
|
|
6543
|
+
case 0: return [4 /*yield*/, this.collection];
|
|
6544
|
+
case 1:
|
|
6545
|
+
_d.sent();
|
|
6546
|
+
_d.label = 2;
|
|
6547
|
+
case 2:
|
|
6548
|
+
_d.trys.push([2, 7, 8, 9]);
|
|
6549
|
+
_a = __values(Object.values(this.args.hash)), _b = _a.next();
|
|
6550
|
+
_d.label = 3;
|
|
6551
|
+
case 3:
|
|
6552
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
6553
|
+
v = _b.value;
|
|
6554
|
+
if (!isValueToken(v)) return [3 /*break*/, 5];
|
|
6555
|
+
return [4 /*yield*/, v];
|
|
6556
|
+
case 4:
|
|
6557
|
+
_d.sent();
|
|
6558
|
+
_d.label = 5;
|
|
6559
|
+
case 5:
|
|
6560
|
+
_b = _a.next();
|
|
6561
|
+
return [3 /*break*/, 3];
|
|
6562
|
+
case 6: return [3 /*break*/, 9];
|
|
6563
|
+
case 7:
|
|
6564
|
+
e_1_1 = _d.sent();
|
|
6565
|
+
e_1 = { error: e_1_1 };
|
|
6566
|
+
return [3 /*break*/, 9];
|
|
6567
|
+
case 8:
|
|
6568
|
+
try {
|
|
6569
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
6570
|
+
}
|
|
6571
|
+
finally { if (e_1) throw e_1.error; }
|
|
6572
|
+
return [7 /*endfinally*/];
|
|
6573
|
+
case 9: return [2 /*return*/];
|
|
6574
|
+
}
|
|
6575
|
+
});
|
|
6576
|
+
};
|
|
6577
|
+
default_1.prototype.blockScope = function () {
|
|
6578
|
+
return [this.variable, 'tablerowloop'];
|
|
6579
|
+
};
|
|
5172
6580
|
return default_1;
|
|
5173
6581
|
}(Tag));
|
|
5174
6582
|
|
|
5175
6583
|
var default_1$f = /** @class */ (function (_super) {
|
|
5176
6584
|
__extends(default_1, _super);
|
|
5177
|
-
function default_1(tagToken, remainTokens, liquid) {
|
|
6585
|
+
function default_1(tagToken, remainTokens, liquid, parser) {
|
|
5178
6586
|
var _this = _super.call(this, tagToken, remainTokens, liquid) || this;
|
|
5179
6587
|
_this.branches = [];
|
|
5180
6588
|
_this.elseTemplates = [];
|
|
5181
6589
|
var p = [];
|
|
5182
6590
|
var elseCount = 0;
|
|
5183
|
-
|
|
6591
|
+
parser.parseStream(remainTokens)
|
|
5184
6592
|
.on('start', function () { return _this.branches.push({
|
|
5185
|
-
value: new Value(tagToken.
|
|
6593
|
+
value: new Value(tagToken.tokenizer.readFilteredValue(), _this.liquid),
|
|
5186
6594
|
test: isFalsy,
|
|
5187
6595
|
templates: (p = [])
|
|
5188
6596
|
}); })
|
|
@@ -5192,7 +6600,7 @@
|
|
|
5192
6600
|
return;
|
|
5193
6601
|
}
|
|
5194
6602
|
_this.branches.push({
|
|
5195
|
-
value: new Value(token.
|
|
6603
|
+
value: new Value(token.tokenizer.readFilteredValue(), _this.liquid),
|
|
5196
6604
|
test: isTruthy,
|
|
5197
6605
|
templates: (p = [])
|
|
5198
6606
|
});
|
|
@@ -5255,6 +6663,19 @@
|
|
|
5255
6663
|
}
|
|
5256
6664
|
});
|
|
5257
6665
|
};
|
|
6666
|
+
default_1.prototype.children = function () {
|
|
6667
|
+
var children;
|
|
6668
|
+
return __generator(this, function (_a) {
|
|
6669
|
+
children = this.branches.flatMap(function (b) { return b.templates; });
|
|
6670
|
+
if (this.elseTemplates) {
|
|
6671
|
+
children.push.apply(children, __spreadArray([], __read(this.elseTemplates), false));
|
|
6672
|
+
}
|
|
6673
|
+
return [2 /*return*/, children];
|
|
6674
|
+
});
|
|
6675
|
+
};
|
|
6676
|
+
default_1.prototype.arguments = function () {
|
|
6677
|
+
return this.branches.map(function (b) { return b.value; });
|
|
6678
|
+
};
|
|
5258
6679
|
return default_1;
|
|
5259
6680
|
}(Tag));
|
|
5260
6681
|
|
|
@@ -5263,8 +6684,8 @@
|
|
|
5263
6684
|
function default_1() {
|
|
5264
6685
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5265
6686
|
}
|
|
5266
|
-
default_1.prototype.render = function (ctx,
|
|
5267
|
-
|
|
6687
|
+
default_1.prototype.render = function (ctx, _emitter) {
|
|
6688
|
+
ctx.breakCalled = true;
|
|
5268
6689
|
};
|
|
5269
6690
|
return default_1;
|
|
5270
6691
|
}(Tag));
|
|
@@ -5274,8 +6695,8 @@
|
|
|
5274
6695
|
function default_1() {
|
|
5275
6696
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
5276
6697
|
}
|
|
5277
|
-
default_1.prototype.render = function (ctx,
|
|
5278
|
-
|
|
6698
|
+
default_1.prototype.render = function (ctx, _emitter) {
|
|
6699
|
+
ctx.continueCalled = true;
|
|
5279
6700
|
};
|
|
5280
6701
|
return default_1;
|
|
5281
6702
|
}(Tag));
|
|
@@ -5305,15 +6726,28 @@
|
|
|
5305
6726
|
}
|
|
5306
6727
|
});
|
|
5307
6728
|
};
|
|
6729
|
+
default_1.prototype.arguments = function () {
|
|
6730
|
+
return __generator(this, function (_a) {
|
|
6731
|
+
switch (_a.label) {
|
|
6732
|
+
case 0:
|
|
6733
|
+
if (!this.value) return [3 /*break*/, 2];
|
|
6734
|
+
return [4 /*yield*/, this.value];
|
|
6735
|
+
case 1:
|
|
6736
|
+
_a.sent();
|
|
6737
|
+
_a.label = 2;
|
|
6738
|
+
case 2: return [2 /*return*/];
|
|
6739
|
+
}
|
|
6740
|
+
});
|
|
6741
|
+
};
|
|
5308
6742
|
return default_1;
|
|
5309
6743
|
}(Tag));
|
|
5310
6744
|
|
|
5311
6745
|
var default_1$j = /** @class */ (function (_super) {
|
|
5312
6746
|
__extends(default_1, _super);
|
|
5313
|
-
function default_1(token, remainTokens, liquid) {
|
|
6747
|
+
function default_1(token, remainTokens, liquid, parser) {
|
|
5314
6748
|
var _this = _super.call(this, token, remainTokens, liquid) || this;
|
|
5315
6749
|
var tokens = _this.tokenizer.readLiquidTagTokens(_this.liquid.options);
|
|
5316
|
-
_this.templates =
|
|
6750
|
+
_this.templates = parser.parseTokens(tokens);
|
|
5317
6751
|
return _this;
|
|
5318
6752
|
}
|
|
5319
6753
|
default_1.prototype.render = function (ctx, emitter) {
|
|
@@ -5326,6 +6760,11 @@
|
|
|
5326
6760
|
}
|
|
5327
6761
|
});
|
|
5328
6762
|
};
|
|
6763
|
+
default_1.prototype.children = function () {
|
|
6764
|
+
return __generator(this, function (_a) {
|
|
6765
|
+
return [2 /*return*/, this.templates];
|
|
6766
|
+
});
|
|
6767
|
+
};
|
|
5329
6768
|
return default_1;
|
|
5330
6769
|
}(Tag));
|
|
5331
6770
|
|
|
@@ -5374,12 +6813,14 @@
|
|
|
5374
6813
|
this.filters = {};
|
|
5375
6814
|
this.tags = {};
|
|
5376
6815
|
this.options = normalize(opts);
|
|
6816
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
5377
6817
|
this.parser = new Parser(this);
|
|
5378
6818
|
forOwn(tags, function (conf, name) { return _this.registerTag(name, conf); });
|
|
5379
6819
|
forOwn(filters, function (handler, name) { return _this.registerFilter(name, handler); });
|
|
5380
6820
|
}
|
|
5381
6821
|
Liquid.prototype.parse = function (html, filepath) {
|
|
5382
|
-
|
|
6822
|
+
var parser = new Parser(this);
|
|
6823
|
+
return parser.parse(html, filepath);
|
|
5383
6824
|
};
|
|
5384
6825
|
Liquid.prototype._render = function (tpl, scope, renderOptions) {
|
|
5385
6826
|
var ctx = scope instanceof Context ? scope : new Context(scope, this.options, renderOptions);
|
|
@@ -5415,23 +6856,23 @@
|
|
|
5415
6856
|
return toValueSync(this._parseAndRender(html, scope, __assign(__assign({}, renderOptions), { sync: true })));
|
|
5416
6857
|
};
|
|
5417
6858
|
Liquid.prototype._parsePartialFile = function (file, sync, currentFile) {
|
|
5418
|
-
return this.
|
|
6859
|
+
return new Parser(this).parseFile(file, sync, LookupType.Partials, currentFile);
|
|
5419
6860
|
};
|
|
5420
6861
|
Liquid.prototype._parseLayoutFile = function (file, sync, currentFile) {
|
|
5421
|
-
return this.
|
|
6862
|
+
return new Parser(this).parseFile(file, sync, LookupType.Layouts, currentFile);
|
|
5422
6863
|
};
|
|
5423
6864
|
Liquid.prototype._parseFile = function (file, sync, lookupType, currentFile) {
|
|
5424
|
-
return this.
|
|
6865
|
+
return new Parser(this).parseFile(file, sync, lookupType, currentFile);
|
|
5425
6866
|
};
|
|
5426
6867
|
Liquid.prototype.parseFile = function (file, lookupType) {
|
|
5427
6868
|
return __awaiter(this, void 0, void 0, function () {
|
|
5428
6869
|
return __generator(this, function (_a) {
|
|
5429
|
-
return [2 /*return*/, toPromise(this.
|
|
6870
|
+
return [2 /*return*/, toPromise(new Parser(this).parseFile(file, false, lookupType))];
|
|
5430
6871
|
});
|
|
5431
6872
|
});
|
|
5432
6873
|
};
|
|
5433
6874
|
Liquid.prototype.parseFileSync = function (file, lookupType) {
|
|
5434
|
-
return toValueSync(this.
|
|
6875
|
+
return toValueSync(new Parser(this).parseFile(file, true, lookupType));
|
|
5435
6876
|
};
|
|
5436
6877
|
Liquid.prototype._renderFile = function (file, ctx, renderFileOptions) {
|
|
5437
6878
|
var templates;
|
|
@@ -5507,11 +6948,161 @@
|
|
|
5507
6948
|
self.renderFile(filePath, ctx).then(function (html) { return callback(null, html); }, callback);
|
|
5508
6949
|
};
|
|
5509
6950
|
};
|
|
6951
|
+
Liquid.prototype.analyze = function (template, options) {
|
|
6952
|
+
if (options === void 0) { options = {}; }
|
|
6953
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6954
|
+
return __generator(this, function (_a) {
|
|
6955
|
+
return [2 /*return*/, analyze(template, options)];
|
|
6956
|
+
});
|
|
6957
|
+
});
|
|
6958
|
+
};
|
|
6959
|
+
Liquid.prototype.analyzeSync = function (template, options) {
|
|
6960
|
+
if (options === void 0) { options = {}; }
|
|
6961
|
+
return analyzeSync(template, options);
|
|
6962
|
+
};
|
|
6963
|
+
Liquid.prototype.parseAndAnalyze = function (html, filename, options) {
|
|
6964
|
+
if (options === void 0) { options = {}; }
|
|
6965
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6966
|
+
return __generator(this, function (_a) {
|
|
6967
|
+
return [2 /*return*/, analyze(this.parse(html, filename), options)];
|
|
6968
|
+
});
|
|
6969
|
+
});
|
|
6970
|
+
};
|
|
6971
|
+
Liquid.prototype.parseAndAnalyzeSync = function (html, filename, options) {
|
|
6972
|
+
if (options === void 0) { options = {}; }
|
|
6973
|
+
return analyzeSync(this.parse(html, filename), options);
|
|
6974
|
+
};
|
|
6975
|
+
/** Return an array of all variables without their properties. */
|
|
6976
|
+
Liquid.prototype.variables = function (template, options) {
|
|
6977
|
+
if (options === void 0) { options = {}; }
|
|
6978
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6979
|
+
var analysis;
|
|
6980
|
+
return __generator(this, function (_a) {
|
|
6981
|
+
switch (_a.label) {
|
|
6982
|
+
case 0: return [4 /*yield*/, analyze(isString(template) ? this.parse(template) : template, options)];
|
|
6983
|
+
case 1:
|
|
6984
|
+
analysis = _a.sent();
|
|
6985
|
+
return [2 /*return*/, Object.keys(analysis.variables)];
|
|
6986
|
+
}
|
|
6987
|
+
});
|
|
6988
|
+
});
|
|
6989
|
+
};
|
|
6990
|
+
/** Return an array of all variables without their properties. */
|
|
6991
|
+
Liquid.prototype.variablesSync = function (template, options) {
|
|
6992
|
+
if (options === void 0) { options = {}; }
|
|
6993
|
+
var analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
|
|
6994
|
+
return Object.keys(analysis.variables);
|
|
6995
|
+
};
|
|
6996
|
+
/** Return an array of all variables including their properties/paths. */
|
|
6997
|
+
Liquid.prototype.fullVariables = function (template, options) {
|
|
6998
|
+
if (options === void 0) { options = {}; }
|
|
6999
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7000
|
+
var analysis;
|
|
7001
|
+
return __generator(this, function (_a) {
|
|
7002
|
+
switch (_a.label) {
|
|
7003
|
+
case 0: return [4 /*yield*/, analyze(isString(template) ? this.parse(template) : template, options)];
|
|
7004
|
+
case 1:
|
|
7005
|
+
analysis = _a.sent();
|
|
7006
|
+
return [2 /*return*/, Array.from(new Set(Object.values(analysis.variables).flatMap(function (a) { return a.map(function (v) { return String(v); }); })))];
|
|
7007
|
+
}
|
|
7008
|
+
});
|
|
7009
|
+
});
|
|
7010
|
+
};
|
|
7011
|
+
/** Return an array of all variables including their properties/paths. */
|
|
7012
|
+
Liquid.prototype.fullVariablesSync = function (template, options) {
|
|
7013
|
+
if (options === void 0) { options = {}; }
|
|
7014
|
+
var analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
|
|
7015
|
+
return Array.from(new Set(Object.values(analysis.variables).flatMap(function (a) { return a.map(function (v) { return String(v); }); })));
|
|
7016
|
+
};
|
|
7017
|
+
/** Return an array of all variables, each as an array of properties/segments. */
|
|
7018
|
+
Liquid.prototype.variableSegments = function (template, options) {
|
|
7019
|
+
if (options === void 0) { options = {}; }
|
|
7020
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7021
|
+
var analysis;
|
|
7022
|
+
return __generator(this, function (_a) {
|
|
7023
|
+
switch (_a.label) {
|
|
7024
|
+
case 0: return [4 /*yield*/, analyze(isString(template) ? this.parse(template) : template, options)];
|
|
7025
|
+
case 1:
|
|
7026
|
+
analysis = _a.sent();
|
|
7027
|
+
return [2 /*return*/, Array.from(strictUniq(Object.values(analysis.variables).flatMap(function (a) { return a.map(function (v) { return v.toArray(); }); })))];
|
|
7028
|
+
}
|
|
7029
|
+
});
|
|
7030
|
+
});
|
|
7031
|
+
};
|
|
7032
|
+
/** Return an array of all variables, each as an array of properties/segments. */
|
|
7033
|
+
Liquid.prototype.variableSegmentsSync = function (template, options) {
|
|
7034
|
+
if (options === void 0) { options = {}; }
|
|
7035
|
+
var analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
|
|
7036
|
+
return Array.from(strictUniq(Object.values(analysis.variables).flatMap(function (a) { return a.map(function (v) { return v.toArray(); }); })));
|
|
7037
|
+
};
|
|
7038
|
+
/** Return an array of all expected context variables without their properties. */
|
|
7039
|
+
Liquid.prototype.globalVariables = function (template, options) {
|
|
7040
|
+
if (options === void 0) { options = {}; }
|
|
7041
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7042
|
+
var analysis;
|
|
7043
|
+
return __generator(this, function (_a) {
|
|
7044
|
+
switch (_a.label) {
|
|
7045
|
+
case 0: return [4 /*yield*/, analyze(isString(template) ? this.parse(template) : template, options)];
|
|
7046
|
+
case 1:
|
|
7047
|
+
analysis = _a.sent();
|
|
7048
|
+
return [2 /*return*/, Object.keys(analysis.globals)];
|
|
7049
|
+
}
|
|
7050
|
+
});
|
|
7051
|
+
});
|
|
7052
|
+
};
|
|
7053
|
+
/** Return an array of all expected context variables without their properties. */
|
|
7054
|
+
Liquid.prototype.globalVariablesSync = function (template, options) {
|
|
7055
|
+
if (options === void 0) { options = {}; }
|
|
7056
|
+
var analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
|
|
7057
|
+
return Object.keys(analysis.globals);
|
|
7058
|
+
};
|
|
7059
|
+
/** Return an array of all expected context variables including their properties/paths. */
|
|
7060
|
+
Liquid.prototype.globalFullVariables = function (template, options) {
|
|
7061
|
+
if (options === void 0) { options = {}; }
|
|
7062
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7063
|
+
var analysis;
|
|
7064
|
+
return __generator(this, function (_a) {
|
|
7065
|
+
switch (_a.label) {
|
|
7066
|
+
case 0: return [4 /*yield*/, analyze(isString(template) ? this.parse(template) : template, options)];
|
|
7067
|
+
case 1:
|
|
7068
|
+
analysis = _a.sent();
|
|
7069
|
+
return [2 /*return*/, Array.from(new Set(Object.values(analysis.globals).flatMap(function (a) { return a.map(function (v) { return String(v); }); })))];
|
|
7070
|
+
}
|
|
7071
|
+
});
|
|
7072
|
+
});
|
|
7073
|
+
};
|
|
7074
|
+
/** Return an array of all expected context variables including their properties/paths. */
|
|
7075
|
+
Liquid.prototype.globalFullVariablesSync = function (template, options) {
|
|
7076
|
+
if (options === void 0) { options = {}; }
|
|
7077
|
+
var analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
|
|
7078
|
+
return Array.from(new Set(Object.values(analysis.globals).flatMap(function (a) { return a.map(function (v) { return String(v); }); })));
|
|
7079
|
+
};
|
|
7080
|
+
/** Return an array of all expected context variables, each as an array of properties/segments. */
|
|
7081
|
+
Liquid.prototype.globalVariableSegments = function (template, options) {
|
|
7082
|
+
if (options === void 0) { options = {}; }
|
|
7083
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7084
|
+
var analysis;
|
|
7085
|
+
return __generator(this, function (_a) {
|
|
7086
|
+
switch (_a.label) {
|
|
7087
|
+
case 0: return [4 /*yield*/, analyze(isString(template) ? this.parse(template) : template, options)];
|
|
7088
|
+
case 1:
|
|
7089
|
+
analysis = _a.sent();
|
|
7090
|
+
return [2 /*return*/, Array.from(strictUniq(Object.values(analysis.globals).flatMap(function (a) { return a.map(function (v) { return v.toArray(); }); })))];
|
|
7091
|
+
}
|
|
7092
|
+
});
|
|
7093
|
+
});
|
|
7094
|
+
};
|
|
7095
|
+
/** Return an array of all expected context variables, each as an array of properties/segments. */
|
|
7096
|
+
Liquid.prototype.globalVariableSegmentsSync = function (template, options) {
|
|
7097
|
+
if (options === void 0) { options = {}; }
|
|
7098
|
+
var analysis = analyzeSync(isString(template) ? this.parse(template) : template, options);
|
|
7099
|
+
return Array.from(strictUniq(Object.values(analysis.globals).flatMap(function (a) { return a.map(function (v) { return v.toArray(); }); })));
|
|
7100
|
+
};
|
|
5510
7101
|
return Liquid;
|
|
5511
7102
|
}());
|
|
5512
7103
|
|
|
5513
7104
|
/* istanbul ignore file */
|
|
5514
|
-
var version = '10.
|
|
7105
|
+
var version = '10.20.1';
|
|
5515
7106
|
|
|
5516
7107
|
exports.AssertionError = AssertionError;
|
|
5517
7108
|
exports.AssignTag = default_1;
|
|
@@ -5541,13 +7132,13 @@
|
|
|
5541
7132
|
exports.Output = Output;
|
|
5542
7133
|
exports.ParseError = ParseError;
|
|
5543
7134
|
exports.ParseStream = ParseStream;
|
|
7135
|
+
exports.Parser = Parser;
|
|
5544
7136
|
exports.RawTag = default_1$d;
|
|
5545
7137
|
exports.RenderError = RenderError;
|
|
5546
7138
|
exports.RenderTag = default_1$5;
|
|
5547
7139
|
exports.TablerowTag = default_1$e;
|
|
5548
7140
|
exports.Tag = Tag;
|
|
5549
7141
|
exports.TagToken = TagToken;
|
|
5550
|
-
exports.TimezoneDate = TimezoneDate;
|
|
5551
7142
|
exports.Token = Token;
|
|
5552
7143
|
exports.TokenizationError = TokenizationError;
|
|
5553
7144
|
exports.Tokenizer = Tokenizer;
|
|
@@ -5555,6 +7146,9 @@
|
|
|
5555
7146
|
exports.UndefinedVariableError = UndefinedVariableError;
|
|
5556
7147
|
exports.UnlessTag = default_1$f;
|
|
5557
7148
|
exports.Value = Value;
|
|
7149
|
+
exports.Variable = Variable;
|
|
7150
|
+
exports.analyze = analyze;
|
|
7151
|
+
exports.analyzeSync = analyzeSync;
|
|
5558
7152
|
exports.assert = assert;
|
|
5559
7153
|
exports.createTrie = createTrie;
|
|
5560
7154
|
exports.defaultOperators = defaultOperators;
|