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