janja 0.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -15,7 +15,10 @@ function highlightSource(message, source, ranges) {
15
15
  let cursor = 0;
16
16
  let caretLinesCount = 0;
17
17
  lines.forEach((line, index) => {
18
- output.push(`${`${`${index + 1}: `.padStart(indentWidth, ' ')}`}${line}`);
18
+ if (!line) {
19
+ return;
20
+ }
21
+ output.push(`${`${index + 1}: `.padStart(indentWidth, ' ')}${line}`);
19
22
  ranges.forEach((tag) => {
20
23
  if (tag.start < cursor) {
21
24
  ranges.splice(ranges.indexOf(tag), 1);
@@ -109,15 +112,16 @@ class Context {
109
112
  });
110
113
  }
111
114
  in() {
112
- const len = this.contexts.push(`${this.context}_${this.index++}`);
113
- return (this.context = this.contexts[len - 1]);
115
+ this.context = `${this.context}_${this.index++}`;
116
+ this.contexts.push(this.context);
117
+ return this.context;
114
118
  }
115
119
  out() {
116
120
  if (this.context === CONTEXT) {
117
121
  return;
118
122
  }
119
123
  this.contexts.pop();
120
- this.context = this.contexts[this.contexts.length - 1];
124
+ this.context = this.contexts.at(-1) ?? CONTEXT;
121
125
  }
122
126
  expect(name) {
123
127
  this.expected.push(name);
@@ -282,32 +286,32 @@ class Compiler {
282
286
  value: options
283
287
  });
284
288
  }
285
- async compile(tagToken, filepath) {
289
+ async compile(tag, filepath) {
286
290
  const ctx = new Context(this.options);
287
291
  const out = new OutScript(this.options);
288
292
  const sourcemap = new SourceMap(this.options);
289
293
  out.start();
290
- while (tagToken) {
291
- const compilers = (this.options.compilers[tagToken.name] ?? []);
294
+ while (tag) {
295
+ const compilers = (this.options.compilers[tag.name] ?? []);
292
296
  for (const compiler of compilers) {
293
297
  try {
294
298
  const r = await compiler.compile({
295
- token: tagToken,
299
+ tag,
296
300
  ctx,
297
301
  out,
298
302
  });
299
303
  if (r !== false) {
300
304
  if (r) {
301
- sourcemap.addMapping(tagToken, r);
305
+ sourcemap.addMapping(tag, r);
302
306
  }
303
307
  break;
304
308
  }
305
309
  }
306
310
  catch (error) {
307
- throw new CompileError(error.message, tagToken, filepath);
311
+ throw new CompileError(error.message, tag, filepath);
308
312
  }
309
313
  }
310
- tagToken = tagToken.next;
314
+ tag = tag.next;
311
315
  }
312
316
  try {
313
317
  ctx.validate();
@@ -324,66 +328,6 @@ class Compiler {
324
328
  }
325
329
  }
326
330
 
327
- const hasOwn = Object.prototype.hasOwnProperty;
328
- function translate(translations = {}, key, params = {}) {
329
- return (hasOwn.call(translations, key) ? translations[key] : key).replace(/\{(.+?)\}/g, (_, name) => (hasOwn.call(params, name) ? params[name] : _));
330
- }
331
-
332
- const monthNames = [
333
- 'January',
334
- 'February',
335
- 'March',
336
- 'April',
337
- 'May',
338
- 'June',
339
- 'July',
340
- 'August',
341
- 'September',
342
- 'October',
343
- 'November',
344
- 'December',
345
- ];
346
- const shortMonthNames = [
347
- 'Jan',
348
- 'Feb',
349
- 'Mar',
350
- 'Apr',
351
- 'May',
352
- 'Jun',
353
- 'Jul',
354
- 'Aug',
355
- 'Sep',
356
- 'Oct',
357
- 'Nov',
358
- 'Dec',
359
- ];
360
- const dayNames = [
361
- 'Sunday',
362
- 'Monday',
363
- 'Tuesday',
364
- 'Wednesday',
365
- 'Thursday',
366
- 'Friday',
367
- 'Saturday',
368
- ];
369
- const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
370
- const o = {
371
- y: d => `${d.getUTCFullYear()}`,
372
- M: (d, len) => `${d.getUTCMonth() + 1}`.padStart(len, '0'),
373
- N: (d, len, translations) => translate(translations, (len > 1 ? monthNames : shortMonthNames)[d.getUTCMonth()]),
374
- d: (d, len) => `${d.getUTCDate()}`.padStart(len, '0'),
375
- h: (d, len) => `${d.getUTCHours()}`.padStart(len, '0'),
376
- m: (d, len) => `${d.getUTCMinutes()}`.padStart(len, '0'),
377
- s: (d, len) => `${d.getUTCSeconds()}`.padStart(len, '0'),
378
- D: (d, len, translations) => translate(translations, (len > 1 ? dayNames : shortDayNames)[d.getUTCDay()]),
379
- };
380
- function formatDatetime(translations = {}, value = 0, format) {
381
- const d = new Date(value);
382
- return format.replace(/y+|M+|N+|d+|h+|m+|s+|D+/g, (str) => {
383
- return o[str[0]](d, str.length, translations);
384
- });
385
- }
386
-
387
331
  class Safe extends String {
388
332
  constructor(value) {
389
333
  super(`${value}`);
@@ -414,8 +358,8 @@ function ceil(value = 0) {
414
358
  function compact(value = []) {
415
359
  return value.filter(v => v != null);
416
360
  }
417
- function date(value = 0, format = 'yy-MM-dd hh:mm') {
418
- return formatDatetime(this.translations, value, format);
361
+ function div(value = 0, divisor = 1) {
362
+ return value / divisor;
419
363
  }
420
364
  function entries(value = {}) {
421
365
  return Object.entries(value);
@@ -468,8 +412,8 @@ function max(value = 0, ...values) {
468
412
  function min(value = 0, ...values) {
469
413
  return Math.min(value, ...values);
470
414
  }
471
- function minus(value = 0, minuend = 0) {
472
- return value - minuend;
415
+ function mul(value = 0, multiplier = 1) {
416
+ return value * multiplier;
473
417
  }
474
418
  function odd(value = 0) {
475
419
  return +value % 2 === 1;
@@ -501,15 +445,12 @@ function sort(value = []) {
501
445
  function split(value = '', separator = '') {
502
446
  return value.split(separator);
503
447
  }
448
+ function sub(value = 0, subtrahend = 0) {
449
+ return value - subtrahend;
450
+ }
504
451
  function sum(value = []) {
505
452
  return value.reduce((a, b) => a + b, 0);
506
453
  }
507
- function t(value, params) {
508
- return translate(this.translations, value, params);
509
- }
510
- function time(value = 0, format = 'hh:mm') {
511
- return formatDatetime(this.translations, value, format);
512
- }
513
454
  function trim(value = '') {
514
455
  return value.trim();
515
456
  }
@@ -541,7 +482,7 @@ var filters = /*#__PURE__*/Object.freeze({
541
482
  capitalize: capitalize,
542
483
  ceil: ceil,
543
484
  compact: compact,
544
- date: date,
485
+ div: div,
545
486
  entries: entries,
546
487
  escape: escape,
547
488
  even: even,
@@ -558,7 +499,7 @@ var filters = /*#__PURE__*/Object.freeze({
558
499
  map: map,
559
500
  max: max,
560
501
  min: min,
561
- minus: minus,
502
+ mul: mul,
562
503
  odd: odd,
563
504
  omit: omit,
564
505
  pick: pick,
@@ -569,9 +510,8 @@ var filters = /*#__PURE__*/Object.freeze({
569
510
  slice: slice,
570
511
  sort: sort,
571
512
  split: split,
513
+ sub: sub,
572
514
  sum: sum,
573
- t: t,
574
- time: time,
575
515
  trim: trim,
576
516
  truncate: truncate,
577
517
  unique: unique,
@@ -584,6 +524,7 @@ var filters = /*#__PURE__*/Object.freeze({
584
524
  const expTokenOperators = {
585
525
  AND: '&&',
586
526
  OR: '||',
527
+ IS: '',
587
528
  NOT: '!',
588
529
  EQ: '===',
589
530
  NE: '!==',
@@ -606,11 +547,9 @@ const expTokenOperators = {
606
547
  COMMA: ',',
607
548
  DOT: '.',
608
549
  ID: '',
609
- STR: '',
610
- NUM: '',
550
+ LIT: '',
611
551
  IF: '',
612
552
  ELSE: '',
613
- BOOL: '',
614
553
  };
615
554
 
616
555
  class ExpCompiler {
@@ -639,18 +578,16 @@ class ExpCompiler {
639
578
  return this.compileNot(expression);
640
579
  case 'ID':
641
580
  return this.compileId(expression);
642
- case 'STR':
643
- return this.compileStr(expression);
644
- case 'NUM':
645
- return this.compileNum(expression);
646
- case 'BOOL':
647
- return this.compileBool(expression);
581
+ case 'LIT':
582
+ return this.compileLit(expression);
648
583
  case 'PIPE':
649
584
  return this.compilePipe(expression);
650
585
  case 'OF':
651
586
  return this.compileOf(expression);
652
587
  case 'SET':
653
588
  return this.compileSet(expression);
589
+ case 'IS':
590
+ return this.compileIs(expression);
654
591
  case 'AND':
655
592
  case 'OR':
656
593
  case 'EQ':
@@ -686,14 +623,8 @@ class ExpCompiler {
686
623
  }
687
624
  return s;
688
625
  }
689
- compileStr({ value }) {
690
- return JSON.stringify(value);
691
- }
692
- compileNum({ value }) {
693
- return value.toString();
694
- }
695
- compileBool({ value }) {
696
- return value.toString();
626
+ compileLit({ value }) {
627
+ return value === undefined ? 'undefined' : JSON.stringify(value);
697
628
  }
698
629
  compileSeq({ elements }) {
699
630
  return elements.map(element => this.compileExp(element)).toString();
@@ -720,6 +651,9 @@ class ExpCompiler {
720
651
  // destructuring
721
652
  return `Object.assign(${this.context},${this.filters}.pick.call(${this.context},${this.compileExp(right)},[${left.elements.map(({ value }) => `"${value}"`).join(',')}]));`;
722
653
  }
654
+ compileIs({ left, right }) {
655
+ return `(typeof ${this.compileExp(left)}===${this.compileExp(right)})`;
656
+ }
723
657
  compileBinary({ type, left, right }) {
724
658
  const ret = `(${this.compileExp(left)}${expTokenOperators[type]}${this.compileExp(right)})`;
725
659
  return type === 'NI' ? `(!${ret})` : ret;
@@ -738,6 +672,7 @@ const expTokenPrecedences = {
738
672
  RP: 20,
739
673
  OR: 25,
740
674
  AND: 30,
675
+ IS: 40,
741
676
  EQ: 40,
742
677
  NE: 40,
743
678
  GT: 40,
@@ -756,15 +691,14 @@ const expTokenPrecedences = {
756
691
  PIPE: 80,
757
692
  DOT: 90,
758
693
  ID: 90,
759
- STR: 90,
760
- NUM: 90,
761
- BOOL: 90,
694
+ LIT: 90,
762
695
  };
763
696
 
764
697
  const expTokenTypes = {
765
698
  'and': 'AND',
766
699
  'or': 'OR',
767
700
  'not': 'NOT',
701
+ 'is': 'IS',
768
702
  'eq': 'EQ',
769
703
  'ne': 'NE',
770
704
  'gt': 'GT',
@@ -781,8 +715,10 @@ const expTokenTypes = {
781
715
  '%': 'MOD',
782
716
  'if': 'IF',
783
717
  'else': 'ELSE',
784
- 'true': 'BOOL',
785
- 'false': 'BOOL',
718
+ 'true': 'LIT',
719
+ 'false': 'LIT',
720
+ 'null': 'LIT',
721
+ 'undefined': 'LIT',
786
722
  '|': 'PIPE',
787
723
  '=': 'SET',
788
724
  '(': 'LP',
@@ -896,7 +832,7 @@ class ExpTokenizer {
896
832
  // skip closing quote char
897
833
  this.cursor++;
898
834
  this.tokens.push({
899
- type: 'STR',
835
+ type: 'LIT',
900
836
  value,
901
837
  start,
902
838
  end: this.cursor,
@@ -922,7 +858,7 @@ class ExpTokenizer {
922
858
  this.cursor++;
923
859
  }
924
860
  this.tokens.push({
925
- type: 'NUM',
861
+ type: 'LIT',
926
862
  value: Number.parseFloat(value),
927
863
  start,
928
864
  end: this.cursor,
@@ -944,7 +880,17 @@ class ExpTokenizer {
944
880
  const type = value in expTokenTypes ? expTokenTypes[value] : 'ID';
945
881
  this.tokens.push({
946
882
  type,
947
- value: type === 'BOOL' ? value === 'true' : value,
883
+ value: type === 'LIT'
884
+ ? value === 'true'
885
+ ? true
886
+ : value === 'false'
887
+ ? false
888
+ : value === 'null'
889
+ ? null
890
+ : value === 'undefined'
891
+ ? undefined
892
+ : value
893
+ : value,
948
894
  start,
949
895
  end: this.cursor,
950
896
  raw: value,
@@ -1098,27 +1044,10 @@ class ExpParser {
1098
1044
  }
1099
1045
  continue;
1100
1046
  }
1101
- if (token.type === 'STR') {
1047
+ if (token.type === 'LIT') {
1102
1048
  left = {
1103
1049
  ...token,
1104
- type: 'STR',
1105
- value: token.value,
1106
- };
1107
- continue;
1108
- }
1109
- if (token.type === 'NUM') {
1110
- left = {
1111
- ...token,
1112
- type: 'NUM',
1113
- value: token.value,
1114
- };
1115
- continue;
1116
- }
1117
- if (token.type === 'BOOL') {
1118
- left = {
1119
- ...token,
1120
- type: 'BOOL',
1121
- value: token.value,
1050
+ type: 'LIT',
1122
1051
  };
1123
1052
  continue;
1124
1053
  }
@@ -1156,6 +1085,7 @@ class ExpParser {
1156
1085
  }
1157
1086
  if (token.type === 'AND'
1158
1087
  || token.type === 'OR'
1088
+ || token.type === 'IS'
1159
1089
  || token.type === 'EQ'
1160
1090
  || token.type === 'NE'
1161
1091
  || token.type === 'GT'
@@ -1334,7 +1264,7 @@ const ENDCALL = 'endcall';
1334
1264
  */
1335
1265
  const tag$7 = {
1336
1266
  names: [CALL, ENDCALL],
1337
- async compile({ token: { name, value }, ctx, out }) {
1267
+ async compile({ tag: { name, value }, ctx, out }) {
1338
1268
  if (name === CALL) {
1339
1269
  if (value?.type !== 'ID') {
1340
1270
  throw new Error(`"${CALL}" tag must specify a "macro" name`);
@@ -1360,7 +1290,7 @@ const ENDCOMMENT = 'endcomment';
1360
1290
  */
1361
1291
  const tag$6 = {
1362
1292
  names: [COMMENT, '#', ENDCOMMENT],
1363
- async compile({ token: { name, value }, ctx, out }) {
1293
+ async compile({ tag: { name, value }, ctx, out }) {
1364
1294
  // inline comment
1365
1295
  if (name === '#') {
1366
1296
  if (!value.value || out.options.stripComments) {
@@ -1389,7 +1319,7 @@ const EXPRESSION = '=';
1389
1319
  */
1390
1320
  const tag$5 = {
1391
1321
  names: [EXPRESSION],
1392
- compile({ token: { value }, ctx: { context }, out }) {
1322
+ compile({ tag: { value }, ctx: { context }, out }) {
1393
1323
  return out.pushVar(compiler.compile(value, context, FILTERS));
1394
1324
  },
1395
1325
  };
@@ -1404,15 +1334,16 @@ const ENDFOR = 'endfor';
1404
1334
  */
1405
1335
  const tag$4 = {
1406
1336
  names: [FOR, BREAK, CONTINUE, ENDFOR],
1407
- async compile({ token: { name, value }, ctx, out }) {
1337
+ async compile({ tag: { name, value }, ctx, out }) {
1408
1338
  if (name === FOR) {
1409
1339
  if (!value) {
1410
1340
  throw new Error(`"${FOR}" tag must have expression`);
1411
1341
  }
1412
1342
  ctx.expect(ENDFOR);
1413
1343
  const { context } = ctx;
1414
- if (value.left.type === 'SEQ') {
1415
- return out.pushLine(`{`, `for(${compiler.compile(value, context, FILTERS)}){`, `const ${ctx.in()}={`, `...${context},`, `${value.left.elements.map(({ value }) => value).join(',')}`, `};`);
1344
+ const { type, elements } = value.left;
1345
+ if (type === 'SEQ') {
1346
+ return out.pushLine(`{`, `for(${compiler.compile(value, context, FILTERS)}){`, `const ${ctx.in()}={`, `...${context},`, elements.map(({ value }) => value).join(','), `};`);
1416
1347
  }
1417
1348
  return out.pushLine(`{`, `for(${compiler.compile(value, context, FILTERS)}){`, `const ${ctx.in()}={`, `...${context},`, `${value.left.value},`, `};`);
1418
1349
  }
@@ -1447,7 +1378,7 @@ const ENDIF = 'endif';
1447
1378
  */
1448
1379
  const tag$3 = {
1449
1380
  names: [IF, ELIF, ELSE, ENDIF],
1450
- async compile({ token: { name, value }, ctx, out }) {
1381
+ async compile({ tag: { name, value }, ctx, out }) {
1451
1382
  if (name === IF) {
1452
1383
  if (!value) {
1453
1384
  throw new Error(`"${IF}" tag must have expression`);
@@ -1484,25 +1415,29 @@ const tag$3 = {
1484
1415
  const MACRO = 'macro';
1485
1416
  const CALLER = 'caller';
1486
1417
  const ENDMACRO = 'endmacro';
1418
+ const CALLER_PN = '_c';
1487
1419
  /**
1488
1420
  * @example {{ macro my_macro = (x, y) }}...{{ caller }}{{ endmacro }}{{ my_macro("foo", 1) }}
1489
1421
  */
1490
1422
  const tag$2 = {
1491
1423
  names: [MACRO, CALLER, ENDMACRO],
1492
- async compile({ token: { name, value }, ctx, out }) {
1424
+ async compile({ tag: { name, value }, ctx, out }) {
1493
1425
  if (name === MACRO) {
1494
1426
  if (value?.type !== 'SET') {
1495
1427
  throw new Error(`"${MACRO}" tag must have "SET" expression`);
1496
1428
  }
1497
1429
  ctx.expect(ENDMACRO);
1498
1430
  const { context } = ctx;
1499
- return out.pushLine(`${compiler.compile(value, context, FILTERS)}=>async(_c)=>{`, `const ${ctx.in()}={`, `...${context},`, `${(value.right.elements).map(el => el.type === 'SET' ? `${el.left.value}` : el.value).join(',')}`, `};`);
1431
+ const { elements } = value.right;
1432
+ return out.pushLine(`${compiler.compile(value, context, FILTERS)}=>async(${CALLER_PN})=>{`, `const ${ctx.in()}={`, `...${context},`, elements.map(el => el.type === 'SET'
1433
+ ? el.left.value
1434
+ : el.value).join(','), `};`);
1500
1435
  }
1501
1436
  if (name === CALLER) {
1502
1437
  if (!ctx.matchAny(ENDMACRO)) {
1503
1438
  throw new Error(`"${CALLER}" tag must inside a "${MACRO}" tag`);
1504
1439
  }
1505
- return out.pushLine(`await _c?.();`);
1440
+ return out.pushLine(`await ${CALLER_PN}?.();`);
1506
1441
  }
1507
1442
  if (name === ENDMACRO) {
1508
1443
  if (!ctx.consume(ENDMACRO)) {
@@ -1520,7 +1455,7 @@ const RAW = 'raw';
1520
1455
  */
1521
1456
  const tag$1 = {
1522
1457
  names: [RAW],
1523
- async compile({ token: { raw, previous, next }, out }) {
1458
+ async compile({ tag: { raw, previous, next }, out }) {
1524
1459
  return out.pushStr(raw, {
1525
1460
  trimStart: previous?.stripAfter,
1526
1461
  trimEnd: next?.stripBefore,
@@ -1536,7 +1471,7 @@ const ENDSET = 'endset';
1536
1471
  */
1537
1472
  const tag = {
1538
1473
  names: [SET, ENDSET],
1539
- async compile({ token: { name, value }, ctx, out }) {
1474
+ async compile({ tag: { name, value }, ctx, out }) {
1540
1475
  if (name === SET) {
1541
1476
  if (!value) {
1542
1477
  throw new Error(`"${SET}" tag must have expression`);
@@ -1644,30 +1579,29 @@ class Parser {
1644
1579
  let match;
1645
1580
  while ((match = tagRe.exec(template))) {
1646
1581
  if (match.index > this.index) {
1647
- this.strToken(this.index, match.index);
1582
+ this.addRaw(this.index, match.index);
1648
1583
  }
1649
- await this.tagToken(match);
1584
+ await this.addTag(match);
1650
1585
  this.index = match.index + match[0].length;
1651
1586
  }
1652
1587
  if (this.index < template.length) {
1653
- this.strToken(this.index, template.length);
1588
+ this.addRaw(this.index, template.length);
1654
1589
  }
1655
1590
  this.cursor = this.first;
1656
1591
  this.rebuildBlocks();
1657
1592
  return this.cursor;
1658
1593
  }
1659
- strToken(start, end) {
1660
- const raw = this.template.slice(start, end);
1594
+ addRaw(start, end) {
1661
1595
  this.push({
1662
1596
  name: RAW$1,
1663
- raw,
1597
+ raw: this.template.slice(start, end),
1664
1598
  previous: null,
1665
1599
  next: null,
1666
1600
  start,
1667
1601
  end,
1668
1602
  });
1669
1603
  }
1670
- async tagToken(match) {
1604
+ async addTag(match) {
1671
1605
  const start = match.index;
1672
1606
  const end = start + match[0].length;
1673
1607
  const base = {
@@ -1684,7 +1618,7 @@ class Parser {
1684
1618
  ...base,
1685
1619
  name: match[2],
1686
1620
  value: {
1687
- type: 'STR',
1621
+ type: 'LIT',
1688
1622
  value: unescapeTag(match[3]),
1689
1623
  },
1690
1624
  });
@@ -1715,7 +1649,7 @@ class Parser {
1715
1649
  }
1716
1650
  async layout(value) {
1717
1651
  const exp = parser.parse(value);
1718
- if (exp?.type !== 'STR' || !exp.value) {
1652
+ if (exp?.type !== 'LIT' || typeof exp.value !== 'string' || !exp.value) {
1719
1653
  throw new ParseError(`"layout" tag must have a file path`, {
1720
1654
  source: this.template,
1721
1655
  range: {
@@ -1728,7 +1662,7 @@ class Parser {
1728
1662
  }
1729
1663
  async include(value) {
1730
1664
  const exp = parser.parse(value.replace(/\?$/, ''));
1731
- if (exp?.type !== 'STR' || !exp.value) {
1665
+ if (exp?.type !== 'LIT' || typeof exp.value !== 'string' || !exp.value) {
1732
1666
  throw new ParseError(`"include" tag must have a file path`, {
1733
1667
  source: this.template,
1734
1668
  range: {
@@ -1759,9 +1693,9 @@ class Parser {
1759
1693
  cursor = cursor.next;
1760
1694
  }
1761
1695
  }
1762
- push(token) {
1763
- if (token.name === BLOCK) {
1764
- const { type, value } = token.value;
1696
+ push(tag) {
1697
+ if (tag.name === BLOCK) {
1698
+ const { type, value } = tag.value;
1765
1699
  if (type !== 'ID') {
1766
1700
  throw new ParseError(`"${BLOCK}" tag must have a title`, {
1767
1701
  source: this.template,
@@ -1774,31 +1708,31 @@ class Parser {
1774
1708
  this.group = value;
1775
1709
  // child blocks
1776
1710
  if (this.blocks[value]) {
1777
- this.blocks[value].push([token]);
1711
+ this.blocks[value].push([tag]);
1778
1712
  return;
1779
1713
  }
1780
1714
  // parent block
1781
- this.blocks[value] = [[token]];
1715
+ this.blocks[value] = [[tag]];
1782
1716
  }
1783
1717
  else if (this.group) {
1784
1718
  const chunks = this.blocks[this.group];
1785
- if (token.name === ENDBLOCK) {
1719
+ if (tag.name === ENDBLOCK) {
1786
1720
  this.group = '';
1787
1721
  }
1788
- chunks.at(-1).push(token);
1722
+ chunks.at(-1).push(tag);
1789
1723
  // child blocks
1790
1724
  if (chunks.length > 1) {
1791
1725
  return;
1792
1726
  }
1793
1727
  }
1794
1728
  if (this.cursor) {
1795
- token.previous = this.cursor;
1796
- this.cursor.next = token;
1729
+ tag.previous = this.cursor;
1730
+ this.cursor.next = tag;
1797
1731
  }
1798
1732
  else {
1799
- this.first = token;
1733
+ this.first = tag;
1800
1734
  }
1801
- this.cursor = token;
1735
+ this.cursor = tag;
1802
1736
  }
1803
1737
  /**
1804
1738
  * @note Block tags are hoisted to top level
@@ -1836,29 +1770,29 @@ class Parser {
1836
1770
  return [];
1837
1771
  }
1838
1772
  const chunk = [];
1839
- child.forEach((token) => {
1840
- if (token.name === SUPER) {
1773
+ child.forEach((tag) => {
1774
+ if (tag.name === SUPER) {
1841
1775
  this.rebuildBlockBody(parents.pop(), parents).forEach(t => chunk.push(t));
1842
1776
  }
1843
1777
  else {
1844
- chunk.push(token);
1778
+ chunk.push(tag);
1845
1779
  }
1846
1780
  });
1847
1781
  return chunk;
1848
1782
  }
1849
- rebuildBlockChain(tokens, previous, next) {
1850
- for (let i = 0; i < tokens.length; i++) {
1851
- tokens[i].previous = tokens[i - 1] || previous;
1852
- tokens[i].next = tokens[i + 1] || next;
1783
+ rebuildBlockChain(tags, previous, next) {
1784
+ for (let i = 0; i < tags.length; i++) {
1785
+ tags[i].previous = tags[i - 1] || previous;
1786
+ tags[i].next = tags[i + 1] || next;
1853
1787
  }
1854
1788
  if (previous) {
1855
- [previous.next] = tokens;
1789
+ [previous.next] = tags;
1856
1790
  }
1857
1791
  if (next) {
1858
- next.previous = tokens[tokens.length - 1];
1792
+ next.previous = tags[tags.length - 1];
1859
1793
  }
1860
1794
  if (!this.first) {
1861
- [this.first] = tokens;
1795
+ [this.first] = tags;
1862
1796
  this.cursor = this.first;
1863
1797
  }
1864
1798
  }