@jaredwray/fumanchu 3.1.2 → 4.0.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/README.md +51 -36
- package/dist/index.cjs +2250 -0
- package/dist/index.d.cts +119 -0
- package/dist/index.d.ts +59 -21
- package/dist/index.js +2114 -2061
- package/package.json +30 -55
package/dist/index.js
CHANGED
|
@@ -1,2087 +1,2105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import * as HandlebarsLib from "handlebars";
|
|
3
|
+
|
|
4
|
+
// src/helpers/array.ts
|
|
5
|
+
var after = (array, n) => {
|
|
6
|
+
if (!Array.isArray(array)) return [];
|
|
7
|
+
return array.slice(n);
|
|
8
|
+
};
|
|
9
|
+
var before = (array, n) => {
|
|
10
|
+
if (!Array.isArray(array)) return [];
|
|
11
|
+
return array.slice(0, -n);
|
|
12
|
+
};
|
|
13
|
+
var arrayify = (value) => {
|
|
14
|
+
if (value == null) return [];
|
|
15
|
+
return Array.isArray(value) ? value : [value];
|
|
16
|
+
};
|
|
17
|
+
var first = (array, n) => {
|
|
18
|
+
if (!Array.isArray(array)) return void 0;
|
|
19
|
+
if (typeof n !== "number") {
|
|
20
|
+
return array[0];
|
|
21
|
+
}
|
|
22
|
+
return array.slice(0, n);
|
|
23
|
+
};
|
|
24
|
+
var last = (value, n) => {
|
|
25
|
+
if (!Array.isArray(value) && typeof value !== "string") {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
if (typeof n !== "number") {
|
|
29
|
+
const array = value;
|
|
30
|
+
return array[array.length - 1];
|
|
31
|
+
}
|
|
32
|
+
const start = Math.abs(n);
|
|
33
|
+
if (typeof value === "string") {
|
|
34
|
+
return value.slice(-start);
|
|
35
|
+
}
|
|
36
|
+
return value.slice(-start);
|
|
37
|
+
};
|
|
38
|
+
var length = (value) => {
|
|
39
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
40
|
+
return Object.keys(value).length;
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === "string" || Array.isArray(value)) {
|
|
43
|
+
return value.length;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
};
|
|
47
|
+
var join = (array, separator = ", ") => {
|
|
48
|
+
if (typeof array === "string") return array;
|
|
49
|
+
if (!Array.isArray(array)) return "";
|
|
50
|
+
return array.join(separator);
|
|
51
|
+
};
|
|
52
|
+
var helpers = [
|
|
53
|
+
{
|
|
54
|
+
name: "after",
|
|
55
|
+
category: "array",
|
|
56
|
+
compatibility: ["browser", "nodejs"],
|
|
57
|
+
fn: after
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "before",
|
|
61
|
+
category: "array",
|
|
62
|
+
compatibility: ["browser", "nodejs"],
|
|
63
|
+
fn: before
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "arrayify",
|
|
67
|
+
category: "array",
|
|
68
|
+
compatibility: ["browser", "nodejs"],
|
|
69
|
+
fn: arrayify
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "first",
|
|
73
|
+
category: "array",
|
|
74
|
+
compatibility: ["browser", "nodejs"],
|
|
75
|
+
fn: first
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "last",
|
|
79
|
+
category: "array",
|
|
80
|
+
compatibility: ["browser", "nodejs"],
|
|
81
|
+
fn: last
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "length",
|
|
85
|
+
category: "array",
|
|
86
|
+
compatibility: ["browser", "nodejs"],
|
|
87
|
+
fn: length
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "join",
|
|
91
|
+
category: "array",
|
|
92
|
+
compatibility: ["browser", "nodejs"],
|
|
93
|
+
fn: join
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
// src/helpers/code.ts
|
|
98
|
+
import fs from "fs";
|
|
99
|
+
import path from "path";
|
|
100
|
+
import tag from "html-tag";
|
|
101
|
+
import codeBlock from "to-gfm-code-block";
|
|
102
|
+
var embed = (filepath, language) => {
|
|
103
|
+
let ext = typeof language === "string" ? language : path.extname(filepath).slice(1);
|
|
104
|
+
let code = fs.readFileSync(filepath, "utf8");
|
|
105
|
+
if (ext === "markdown" || ext === "md") {
|
|
106
|
+
ext = "markdown";
|
|
107
|
+
code = code.split("`").join("`");
|
|
108
|
+
}
|
|
109
|
+
return `${codeBlock(code, ext).trim()}
|
|
110
|
+
`;
|
|
111
|
+
};
|
|
112
|
+
var gist = (id) => {
|
|
113
|
+
return tag("script", { src: `https://gist.github.com/${id}.js` });
|
|
114
|
+
};
|
|
115
|
+
var jsfiddle = (options) => {
|
|
116
|
+
if (!options || !options.id) {
|
|
117
|
+
throw new Error("jsfiddle helper expects an `id`");
|
|
118
|
+
}
|
|
119
|
+
const {
|
|
120
|
+
id,
|
|
121
|
+
width = "100%",
|
|
122
|
+
height = "300",
|
|
123
|
+
skin = "/presentation/",
|
|
124
|
+
tabs = "result,js,html,css",
|
|
125
|
+
allowfullscreen = "allowfullscreen",
|
|
126
|
+
frameborder = "0"
|
|
127
|
+
} = options;
|
|
128
|
+
const src = `http://jsfiddle.net/${id}/embedded/${tabs}${skin}`;
|
|
129
|
+
return tag("iframe", { width, height, src, allowfullscreen, frameborder });
|
|
51
130
|
};
|
|
131
|
+
var helpers2 = [
|
|
132
|
+
{
|
|
133
|
+
name: "embed",
|
|
134
|
+
category: "code",
|
|
135
|
+
compatibility: ["nodejs"],
|
|
136
|
+
fn: embed
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "gist",
|
|
140
|
+
category: "code",
|
|
141
|
+
compatibility: ["browser", "nodejs"],
|
|
142
|
+
fn: gist
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "jsfiddle",
|
|
146
|
+
category: "code",
|
|
147
|
+
compatibility: ["browser", "nodejs"],
|
|
148
|
+
fn: jsfiddle
|
|
149
|
+
}
|
|
150
|
+
];
|
|
52
151
|
|
|
53
|
-
// helpers/
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"nay",
|
|
67
|
-
"nah",
|
|
68
|
-
"negative",
|
|
69
|
-
"no",
|
|
70
|
-
"none",
|
|
71
|
-
"nope",
|
|
72
|
-
"nul",
|
|
73
|
-
"null",
|
|
74
|
-
"nix",
|
|
75
|
-
"nyet",
|
|
76
|
-
"uh-uh",
|
|
77
|
-
"veto",
|
|
78
|
-
"zero"
|
|
79
|
-
];
|
|
80
|
-
if (!Array.isArray(words)) {
|
|
81
|
-
words = [words];
|
|
82
|
-
}
|
|
83
|
-
const lower = typeof val === "string" ? val.toLowerCase() : null;
|
|
84
|
-
for (const word of words) {
|
|
85
|
-
if (word === val) {
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
if (word === lower) {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
152
|
+
// src/helpers/collection.ts
|
|
153
|
+
var isEmpty = (collection) => {
|
|
154
|
+
if (collection == null) return true;
|
|
155
|
+
if (Array.isArray(collection)) return collection.length === 0;
|
|
156
|
+
if (typeof collection === "object")
|
|
157
|
+
return Object.keys(collection).length === 0;
|
|
158
|
+
return false;
|
|
159
|
+
};
|
|
160
|
+
var iterate = (collection, fn, inverse) => {
|
|
161
|
+
if (Array.isArray(collection)) {
|
|
162
|
+
let result = "";
|
|
163
|
+
for (let i = 0; i < collection.length; i++) {
|
|
164
|
+
result += fn(collection[i], i);
|
|
93
165
|
}
|
|
94
|
-
|
|
166
|
+
return result;
|
|
95
167
|
}
|
|
96
|
-
|
|
168
|
+
if (collection && typeof collection === "object") {
|
|
169
|
+
let result = "";
|
|
170
|
+
for (const key of Object.keys(collection)) {
|
|
171
|
+
result += fn(collection[key], key);
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
return inverse ? inverse() : "";
|
|
176
|
+
};
|
|
177
|
+
var helpers3 = [
|
|
178
|
+
{
|
|
179
|
+
name: "isEmpty",
|
|
180
|
+
category: "collection",
|
|
181
|
+
compatibility: ["browser", "nodejs"],
|
|
182
|
+
fn: isEmpty
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "iterate",
|
|
186
|
+
category: "collection",
|
|
187
|
+
compatibility: ["browser", "nodejs"],
|
|
188
|
+
fn: iterate
|
|
189
|
+
}
|
|
190
|
+
];
|
|
97
191
|
|
|
98
|
-
// helpers/
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
192
|
+
// src/helpers/comparison.ts
|
|
193
|
+
var and = (...values) => values.every(Boolean);
|
|
194
|
+
var compare = (a, operator, b) => {
|
|
195
|
+
switch (operator) {
|
|
196
|
+
case "==":
|
|
197
|
+
return a == b;
|
|
198
|
+
// eslint-disable-line eqeqeq
|
|
199
|
+
case "===":
|
|
200
|
+
return a === b;
|
|
201
|
+
case "!=":
|
|
202
|
+
return a != b;
|
|
203
|
+
// eslint-disable-line eqeqeq
|
|
204
|
+
case "!==":
|
|
205
|
+
return a !== b;
|
|
206
|
+
case "<":
|
|
207
|
+
return a < b;
|
|
208
|
+
case ">":
|
|
209
|
+
return a > b;
|
|
210
|
+
case "<=":
|
|
211
|
+
return a <= b;
|
|
212
|
+
case ">=":
|
|
213
|
+
return a >= b;
|
|
214
|
+
case "typeof":
|
|
215
|
+
return typeof a === b;
|
|
216
|
+
default:
|
|
217
|
+
throw new Error(`helper {{compare}}: invalid operator: '${operator}'`);
|
|
123
218
|
}
|
|
124
|
-
}
|
|
219
|
+
};
|
|
220
|
+
var contains = (collection, value, startIndex = 0) => {
|
|
221
|
+
if (collection == null) return false;
|
|
222
|
+
if (typeof collection === "string" || Array.isArray(collection)) {
|
|
223
|
+
return collection.indexOf(value, startIndex) > -1;
|
|
224
|
+
}
|
|
225
|
+
if (typeof collection === "object") {
|
|
226
|
+
return value in collection;
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
};
|
|
230
|
+
var defaultHelper = (...values) => {
|
|
231
|
+
for (const val of values) {
|
|
232
|
+
if (val != null) return val;
|
|
233
|
+
}
|
|
234
|
+
return "";
|
|
235
|
+
};
|
|
236
|
+
var eq = (a, b) => a === b;
|
|
237
|
+
var gt = (a, b) => a > b;
|
|
238
|
+
var gte = (a, b) => a >= b;
|
|
239
|
+
var has = (value, pattern) => {
|
|
240
|
+
if (value == null || pattern == null) return false;
|
|
241
|
+
if (Array.isArray(value) || typeof value === "string") {
|
|
242
|
+
return value.indexOf(pattern) > -1;
|
|
243
|
+
}
|
|
244
|
+
if (typeof value === "object") {
|
|
245
|
+
return pattern in value;
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
};
|
|
249
|
+
var falsey = (val, keywords) => {
|
|
250
|
+
if (!val) return true;
|
|
251
|
+
const words = Array.isArray(keywords) ? keywords : keywords != null ? [keywords] : [
|
|
252
|
+
"0",
|
|
253
|
+
"false",
|
|
254
|
+
"nada",
|
|
255
|
+
"nil",
|
|
256
|
+
"nay",
|
|
257
|
+
"nah",
|
|
258
|
+
"negative",
|
|
259
|
+
"no",
|
|
260
|
+
"none",
|
|
261
|
+
"nope",
|
|
262
|
+
"nul",
|
|
263
|
+
"null",
|
|
264
|
+
"nix",
|
|
265
|
+
"nyet",
|
|
266
|
+
"uh-uh",
|
|
267
|
+
"veto",
|
|
268
|
+
"zero"
|
|
269
|
+
];
|
|
270
|
+
const lower = typeof val === "string" ? val.toLowerCase() : null;
|
|
271
|
+
for (const word of words) {
|
|
272
|
+
if (word === val) return true;
|
|
273
|
+
if (lower != null && word === lower) return true;
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
};
|
|
277
|
+
var isFalsey = (val) => falsey(val);
|
|
278
|
+
var isTruthy = (val) => !falsey(val);
|
|
279
|
+
var ifEven = (num) => typeof num === "number" && num % 2 === 0;
|
|
280
|
+
var ifNth = (a, b) => typeof a === "number" && typeof b === "number" && b % a === 0;
|
|
281
|
+
var ifOdd = (val) => typeof val === "number" && Math.abs(val % 2) === 1;
|
|
282
|
+
var is = (a, b) => a == b;
|
|
283
|
+
var isnt = (a, b) => a != b;
|
|
284
|
+
var lt = (a, b) => a < b;
|
|
285
|
+
var lte = (a, b) => a <= b;
|
|
286
|
+
var neither = (a, b) => !a && !b;
|
|
287
|
+
var not = (val) => !val;
|
|
288
|
+
var or = (...values) => values.some(Boolean);
|
|
289
|
+
var unlessEq = (a, b) => a !== b;
|
|
290
|
+
var unlessGt = (a, b) => a <= b;
|
|
291
|
+
var unlessLt = (a, b) => a >= b;
|
|
292
|
+
var unlessGteq = (a, b) => a < b;
|
|
293
|
+
var unlessLteq = (a, b) => a > b;
|
|
294
|
+
var helpers4 = [
|
|
295
|
+
{
|
|
296
|
+
name: "and",
|
|
297
|
+
category: "comparison",
|
|
298
|
+
compatibility: ["browser", "nodejs"],
|
|
299
|
+
fn: and
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "compare",
|
|
303
|
+
category: "comparison",
|
|
304
|
+
compatibility: ["browser", "nodejs"],
|
|
305
|
+
fn: compare
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: "contains",
|
|
309
|
+
category: "comparison",
|
|
310
|
+
compatibility: ["browser", "nodejs"],
|
|
311
|
+
fn: contains
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: "default",
|
|
315
|
+
category: "comparison",
|
|
316
|
+
compatibility: ["browser", "nodejs"],
|
|
317
|
+
fn: defaultHelper
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "eq",
|
|
321
|
+
category: "comparison",
|
|
322
|
+
compatibility: ["browser", "nodejs"],
|
|
323
|
+
fn: eq
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: "gt",
|
|
327
|
+
category: "comparison",
|
|
328
|
+
compatibility: ["browser", "nodejs"],
|
|
329
|
+
fn: gt
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "gte",
|
|
333
|
+
category: "comparison",
|
|
334
|
+
compatibility: ["browser", "nodejs"],
|
|
335
|
+
fn: gte
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "has",
|
|
339
|
+
category: "comparison",
|
|
340
|
+
compatibility: ["browser", "nodejs"],
|
|
341
|
+
fn: has
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: "isFalsey",
|
|
345
|
+
category: "comparison",
|
|
346
|
+
compatibility: ["browser", "nodejs"],
|
|
347
|
+
fn: isFalsey
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: "isTruthy",
|
|
351
|
+
category: "comparison",
|
|
352
|
+
compatibility: ["browser", "nodejs"],
|
|
353
|
+
fn: isTruthy
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "ifEven",
|
|
357
|
+
category: "comparison",
|
|
358
|
+
compatibility: ["browser", "nodejs"],
|
|
359
|
+
fn: ifEven
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: "ifNth",
|
|
363
|
+
category: "comparison",
|
|
364
|
+
compatibility: ["browser", "nodejs"],
|
|
365
|
+
fn: ifNth
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: "ifOdd",
|
|
369
|
+
category: "comparison",
|
|
370
|
+
compatibility: ["browser", "nodejs"],
|
|
371
|
+
fn: ifOdd
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "is",
|
|
375
|
+
category: "comparison",
|
|
376
|
+
compatibility: ["browser", "nodejs"],
|
|
377
|
+
fn: is
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "isnt",
|
|
381
|
+
category: "comparison",
|
|
382
|
+
compatibility: ["browser", "nodejs"],
|
|
383
|
+
fn: isnt
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
name: "lt",
|
|
387
|
+
category: "comparison",
|
|
388
|
+
compatibility: ["browser", "nodejs"],
|
|
389
|
+
fn: lt
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "lte",
|
|
393
|
+
category: "comparison",
|
|
394
|
+
compatibility: ["browser", "nodejs"],
|
|
395
|
+
fn: lte
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
name: "neither",
|
|
399
|
+
category: "comparison",
|
|
400
|
+
compatibility: ["browser", "nodejs"],
|
|
401
|
+
fn: neither
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: "not",
|
|
405
|
+
category: "comparison",
|
|
406
|
+
compatibility: ["browser", "nodejs"],
|
|
407
|
+
fn: not
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "or",
|
|
411
|
+
category: "comparison",
|
|
412
|
+
compatibility: ["browser", "nodejs"],
|
|
413
|
+
fn: or
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
name: "unlessEq",
|
|
417
|
+
category: "comparison",
|
|
418
|
+
compatibility: ["browser", "nodejs"],
|
|
419
|
+
fn: unlessEq
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: "unlessGt",
|
|
423
|
+
category: "comparison",
|
|
424
|
+
compatibility: ["browser", "nodejs"],
|
|
425
|
+
fn: unlessGt
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
name: "unlessLt",
|
|
429
|
+
category: "comparison",
|
|
430
|
+
compatibility: ["browser", "nodejs"],
|
|
431
|
+
fn: unlessLt
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: "unlessGteq",
|
|
435
|
+
category: "comparison",
|
|
436
|
+
compatibility: ["browser", "nodejs"],
|
|
437
|
+
fn: unlessGteq
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: "unlessLteq",
|
|
441
|
+
category: "comparison",
|
|
442
|
+
compatibility: ["browser", "nodejs"],
|
|
443
|
+
fn: unlessLteq
|
|
444
|
+
}
|
|
445
|
+
];
|
|
125
446
|
|
|
126
|
-
// helpers/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
return val.indexOf(obj, start) !== -1;
|
|
137
|
-
};
|
|
138
|
-
utils.chop = function(str) {
|
|
139
|
-
if (!util.isString(str)) return "";
|
|
140
|
-
var re = /^[-_.\W\s]+|[-_.\W\s]+$/g;
|
|
141
|
-
if (str.length > 1e3) {
|
|
142
|
-
throw new Error("utils.chop() regex is too long!");
|
|
143
|
-
}
|
|
144
|
-
return str.trim().replace(re, "");
|
|
145
|
-
};
|
|
146
|
-
utils.changecase = function(str, fn) {
|
|
147
|
-
if (!util.isString(str)) return "";
|
|
148
|
-
if (str.length === 1) {
|
|
149
|
-
return str.toLowerCase();
|
|
150
|
-
}
|
|
151
|
-
str = utils.chop(str).toLowerCase();
|
|
152
|
-
if (typeof fn !== "function") {
|
|
153
|
-
fn = utils.identity;
|
|
154
|
-
}
|
|
155
|
-
var re = /[-_.\W\s]+(\w|$)/g;
|
|
156
|
-
return str.replace(re, function(_, ch) {
|
|
157
|
-
return fn(ch);
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
utils.random = function(min, max) {
|
|
161
|
-
return min + Math.floor(Math.random() * (max - min + 1));
|
|
162
|
-
};
|
|
163
|
-
module2.exports = utils;
|
|
447
|
+
// src/helpers/date.ts
|
|
448
|
+
import { parseDate } from "chrono-node";
|
|
449
|
+
import dayjs from "dayjs";
|
|
450
|
+
var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
451
|
+
var date = (humanReadableDate, formatString) => {
|
|
452
|
+
const parsedDate = parseDate(humanReadableDate);
|
|
453
|
+
if (!parsedDate) {
|
|
454
|
+
throw new Error(`Unable to parse date: ${humanReadableDate}`);
|
|
164
455
|
}
|
|
165
|
-
|
|
456
|
+
return dayjs(parsedDate).format(formatString);
|
|
457
|
+
};
|
|
458
|
+
var helpers5 = [
|
|
459
|
+
{
|
|
460
|
+
name: "year",
|
|
461
|
+
category: "date",
|
|
462
|
+
compatibility: ["browser", "nodejs"],
|
|
463
|
+
fn: year
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: "date",
|
|
467
|
+
category: "date",
|
|
468
|
+
compatibility: ["browser", "nodejs"],
|
|
469
|
+
fn: date
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
/* Adding this in for legacy support */
|
|
473
|
+
name: "moment",
|
|
474
|
+
category: "date",
|
|
475
|
+
compatibility: ["browser", "nodejs"],
|
|
476
|
+
fn: date
|
|
477
|
+
}
|
|
478
|
+
];
|
|
166
479
|
|
|
167
|
-
// helpers/
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (util.isUndefined(array)) return "";
|
|
215
|
-
if (!utils.isNumber(n)) {
|
|
216
|
-
return array[0];
|
|
217
|
-
}
|
|
218
|
-
return array.slice(0, n);
|
|
219
|
-
};
|
|
220
|
-
helpers3.forEach = function(array, options) {
|
|
221
|
-
var data = utils.createFrame(options, options.hash);
|
|
222
|
-
var len = array.length;
|
|
223
|
-
var buffer = "";
|
|
224
|
-
var i = -1;
|
|
225
|
-
while (++i < len) {
|
|
226
|
-
var item = array[i];
|
|
227
|
-
data.index = i;
|
|
228
|
-
item.index = i + 1;
|
|
229
|
-
item.total = len;
|
|
230
|
-
item.isFirst = i === 0;
|
|
231
|
-
item.isLast = i === len - 1;
|
|
232
|
-
buffer += options.fn(item, { data });
|
|
233
|
-
}
|
|
234
|
-
return buffer;
|
|
235
|
-
};
|
|
236
|
-
helpers3.inArray = function(array, value, options) {
|
|
237
|
-
return util.value(util.indexOf(array, value) > -1, this, options);
|
|
238
|
-
};
|
|
239
|
-
helpers3.isArray = function(value) {
|
|
240
|
-
return Array.isArray(value);
|
|
241
|
-
};
|
|
242
|
-
helpers3.itemAt = function(array, idx) {
|
|
243
|
-
array = util.result(array);
|
|
244
|
-
if (Array.isArray(array)) {
|
|
245
|
-
idx = utils.isNumber(idx) ? +idx : 0;
|
|
246
|
-
if (idx < 0) {
|
|
247
|
-
return array[array.length + idx];
|
|
248
|
-
}
|
|
249
|
-
if (idx < array.length) {
|
|
250
|
-
return array[idx];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
helpers3.join = function(array, separator) {
|
|
255
|
-
if (typeof array === "string") return array;
|
|
256
|
-
if (!Array.isArray(array)) return "";
|
|
257
|
-
separator = util.isString(separator) ? separator : ", ";
|
|
258
|
-
return array.join(separator);
|
|
259
|
-
};
|
|
260
|
-
helpers3.equalsLength = function(value, length, options) {
|
|
261
|
-
if (util.isOptions(length)) {
|
|
262
|
-
options = length;
|
|
263
|
-
length = 0;
|
|
264
|
-
}
|
|
265
|
-
var len = 0;
|
|
266
|
-
if (typeof value === "string" || Array.isArray(value)) {
|
|
267
|
-
len = value.length;
|
|
268
|
-
}
|
|
269
|
-
return util.value(len === length, this, options);
|
|
270
|
-
};
|
|
271
|
-
helpers3.last = function(value, n) {
|
|
272
|
-
if (!Array.isArray(value) && typeof value !== "string") {
|
|
273
|
-
return "";
|
|
274
|
-
}
|
|
275
|
-
if (!utils.isNumber(n)) {
|
|
276
|
-
return value[value.length - 1];
|
|
277
|
-
}
|
|
278
|
-
return value.slice(-Math.abs(n));
|
|
279
|
-
};
|
|
280
|
-
helpers3.length = function(value) {
|
|
281
|
-
if (util.isObject(value) && !util.isOptions(value)) {
|
|
282
|
-
value = Object.keys(value);
|
|
283
|
-
}
|
|
284
|
-
if (typeof value === "string" || Array.isArray(value)) {
|
|
285
|
-
return value.length;
|
|
286
|
-
}
|
|
287
|
-
return 0;
|
|
288
|
-
};
|
|
289
|
-
helpers3.lengthEqual = helpers3.equalsLength;
|
|
290
|
-
helpers3.map = function(array, iter) {
|
|
291
|
-
if (!Array.isArray(array)) return "";
|
|
292
|
-
var len = array.length;
|
|
293
|
-
var res = new Array(len);
|
|
294
|
-
var i = -1;
|
|
295
|
-
if (typeof iter !== "function") {
|
|
296
|
-
return array;
|
|
297
|
-
}
|
|
298
|
-
while (++i < len) {
|
|
299
|
-
res[i] = iter(array[i], i, array);
|
|
300
|
-
}
|
|
301
|
-
return res;
|
|
302
|
-
};
|
|
303
|
-
helpers3.pluck = function(arr, prop) {
|
|
304
|
-
if (util.isUndefined(arr)) return "";
|
|
305
|
-
var res = [];
|
|
306
|
-
for (var i = 0; i < arr.length; i++) {
|
|
307
|
-
var val = utils.get(arr[i], prop);
|
|
308
|
-
if (typeof val !== "undefined") {
|
|
309
|
-
res.push(val);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return res;
|
|
313
|
-
};
|
|
314
|
-
helpers3.reverse = function(val) {
|
|
315
|
-
if (Array.isArray(val)) {
|
|
316
|
-
val.reverse();
|
|
317
|
-
return val;
|
|
318
|
-
}
|
|
319
|
-
if (val && typeof val === "string") {
|
|
320
|
-
return val.split("").reverse().join("");
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
helpers3.some = function(array, iter, options) {
|
|
324
|
-
if (Array.isArray(array)) {
|
|
325
|
-
for (var i = 0; i < array.length; i++) {
|
|
326
|
-
if (iter(array[i], i, array)) {
|
|
327
|
-
return options.fn(this);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return options.inverse(this);
|
|
332
|
-
};
|
|
333
|
-
helpers3.sort = function(array, options) {
|
|
334
|
-
if (!Array.isArray(array)) return "";
|
|
335
|
-
if (utils.get(options, "hash.reverse")) {
|
|
336
|
-
return array.sort().reverse();
|
|
337
|
-
}
|
|
338
|
-
return array.sort();
|
|
339
|
-
};
|
|
340
|
-
helpers3.sortBy = function(array, prop, options) {
|
|
341
|
-
if (!Array.isArray(array)) return "";
|
|
342
|
-
var args = [].slice.call(arguments);
|
|
343
|
-
args.pop();
|
|
344
|
-
if (!util.isString(prop) && typeof prop !== "function") {
|
|
345
|
-
return array.sort();
|
|
346
|
-
}
|
|
347
|
-
return utils.sortBy.apply(null, args);
|
|
348
|
-
};
|
|
349
|
-
helpers3.withAfter = function(array, idx, options) {
|
|
350
|
-
if (!Array.isArray(array)) return "";
|
|
351
|
-
array = array.slice(idx);
|
|
352
|
-
var result = "";
|
|
353
|
-
for (var i = 0; i < array.length; i++) {
|
|
354
|
-
result += options.fn(array[i]);
|
|
355
|
-
}
|
|
356
|
-
return result;
|
|
357
|
-
};
|
|
358
|
-
helpers3.withBefore = function(array, idx, options) {
|
|
359
|
-
if (!Array.isArray(array)) return "";
|
|
360
|
-
array = array.slice(0, -idx);
|
|
361
|
-
var result = "";
|
|
362
|
-
for (var i = 0; i < array.length; i++) {
|
|
363
|
-
result += options.fn(array[i]);
|
|
364
|
-
}
|
|
365
|
-
return result;
|
|
366
|
-
};
|
|
367
|
-
helpers3.withFirst = function(array, idx, options) {
|
|
368
|
-
if (util.isUndefined(array)) return "";
|
|
369
|
-
array = util.result(array);
|
|
370
|
-
if (!util.isUndefined(idx)) {
|
|
371
|
-
idx = parseFloat(util.result(idx));
|
|
372
|
-
}
|
|
373
|
-
if (util.isUndefined(idx)) {
|
|
374
|
-
options = idx;
|
|
375
|
-
return options.fn(array[0]);
|
|
376
|
-
}
|
|
377
|
-
array = array.slice(0, idx);
|
|
378
|
-
var result = "";
|
|
379
|
-
for (var i = 0; i < array.length; i++) {
|
|
380
|
-
result += options.fn(array[i]);
|
|
381
|
-
}
|
|
382
|
-
return result;
|
|
383
|
-
};
|
|
384
|
-
helpers3.withGroup = function(array, size, options) {
|
|
385
|
-
var result = "";
|
|
386
|
-
if (Array.isArray(array) && array.length > 0) {
|
|
387
|
-
var subcontext = [];
|
|
388
|
-
for (var i = 0; i < array.length; i++) {
|
|
389
|
-
if (i > 0 && i % size === 0) {
|
|
390
|
-
result += options.fn(subcontext);
|
|
391
|
-
subcontext = [];
|
|
392
|
-
}
|
|
393
|
-
subcontext.push(array[i]);
|
|
394
|
-
}
|
|
395
|
-
result += options.fn(subcontext);
|
|
396
|
-
}
|
|
397
|
-
return result;
|
|
398
|
-
};
|
|
399
|
-
helpers3.withLast = function(array, idx, options) {
|
|
400
|
-
if (util.isUndefined(array)) return "";
|
|
401
|
-
array = util.result(array);
|
|
402
|
-
if (!util.isUndefined(idx)) {
|
|
403
|
-
idx = parseFloat(util.result(idx));
|
|
404
|
-
}
|
|
405
|
-
if (util.isUndefined(idx)) {
|
|
406
|
-
options = idx;
|
|
407
|
-
return options.fn(array[array.length - 1]);
|
|
408
|
-
}
|
|
409
|
-
array = array.slice(-idx);
|
|
410
|
-
var len = array.length, i = -1;
|
|
411
|
-
var result = "";
|
|
412
|
-
while (++i < len) {
|
|
413
|
-
result += options.fn(array[i]);
|
|
414
|
-
}
|
|
415
|
-
return result;
|
|
416
|
-
};
|
|
417
|
-
helpers3.withSort = function(array, prop, options) {
|
|
418
|
-
if (util.isUndefined(array)) return "";
|
|
419
|
-
var result = "";
|
|
420
|
-
if (util.isUndefined(prop)) {
|
|
421
|
-
options = prop;
|
|
422
|
-
array = array.sort();
|
|
423
|
-
if (utils.get(options, "hash.reverse")) {
|
|
424
|
-
array = array.reverse();
|
|
425
|
-
}
|
|
426
|
-
for (var i = 0, len = array.length; i < len; i++) {
|
|
427
|
-
result += options.fn(array[i]);
|
|
428
|
-
}
|
|
429
|
-
return result;
|
|
430
|
-
}
|
|
431
|
-
array.sort(function(a, b) {
|
|
432
|
-
a = utils.get(a, prop);
|
|
433
|
-
b = utils.get(b, prop);
|
|
434
|
-
return a > b ? 1 : a < b ? -1 : 0;
|
|
435
|
-
});
|
|
436
|
-
if (utils.get(options, "hash.reverse")) {
|
|
437
|
-
array = array.reverse();
|
|
438
|
-
}
|
|
439
|
-
var alen = array.length, j = -1;
|
|
440
|
-
while (++j < alen) {
|
|
441
|
-
result += options.fn(array[j]);
|
|
442
|
-
}
|
|
443
|
-
return result;
|
|
444
|
-
};
|
|
445
|
-
helpers3.unique = function(array, options) {
|
|
446
|
-
if (util.isUndefined(array)) return "";
|
|
447
|
-
return array.filter(function(item, index, arr) {
|
|
448
|
-
return arr.indexOf(item) === index;
|
|
480
|
+
// src/helpers/fs.ts
|
|
481
|
+
import fs2 from "fs";
|
|
482
|
+
import path2 from "path";
|
|
483
|
+
import isGlob from "is-glob";
|
|
484
|
+
import micromatch from "micromatch";
|
|
485
|
+
var fileSize = (value, precision) => {
|
|
486
|
+
if (value == null) return "0 B";
|
|
487
|
+
const number = typeof value === "number" ? value : value.length ?? 0;
|
|
488
|
+
if (!number) return "0 B";
|
|
489
|
+
const precisionNumber = typeof precision === "number" ? precision : 2;
|
|
490
|
+
const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
491
|
+
const factor = 10 ** precisionNumber;
|
|
492
|
+
let i = abbr.length - 1;
|
|
493
|
+
do {
|
|
494
|
+
const size = 10 ** (i * 3);
|
|
495
|
+
if (size <= number + 1) {
|
|
496
|
+
const num = Math.round(number * factor / size) / factor;
|
|
497
|
+
return `${num} ${abbr[i]}`;
|
|
498
|
+
}
|
|
499
|
+
} while (--i >= 0);
|
|
500
|
+
return `${number} B`;
|
|
501
|
+
};
|
|
502
|
+
var read = (filepath) => {
|
|
503
|
+
return fs2.readFileSync(filepath, "utf8");
|
|
504
|
+
};
|
|
505
|
+
var isOptions = (value) => {
|
|
506
|
+
return Boolean(
|
|
507
|
+
value && typeof value === "object" && "hash" in value
|
|
508
|
+
);
|
|
509
|
+
};
|
|
510
|
+
var readdir = (dir, filter) => {
|
|
511
|
+
const files = fs2.readdirSync(dir).map((fp) => path2.join(dir, fp));
|
|
512
|
+
const filterArg = isOptions(filter) ? void 0 : filter;
|
|
513
|
+
if (typeof filterArg === "function") {
|
|
514
|
+
return filterArg(files);
|
|
515
|
+
}
|
|
516
|
+
if (filterArg instanceof RegExp) {
|
|
517
|
+
return files.filter((fp) => filterArg.test(fp));
|
|
518
|
+
}
|
|
519
|
+
if (typeof filterArg === "string") {
|
|
520
|
+
if (isGlob(filterArg)) {
|
|
521
|
+
return micromatch(files, filterArg);
|
|
522
|
+
}
|
|
523
|
+
if (filterArg === "isFile" || filterArg === "isDirectory") {
|
|
524
|
+
return files.filter((fp) => {
|
|
525
|
+
const stat = fs2.statSync(fp);
|
|
526
|
+
return filterArg === "isFile" ? stat.isFile() : stat.isDirectory();
|
|
449
527
|
});
|
|
450
|
-
}
|
|
528
|
+
}
|
|
451
529
|
}
|
|
452
|
-
|
|
530
|
+
return files;
|
|
531
|
+
};
|
|
532
|
+
var helpers6 = [
|
|
533
|
+
{
|
|
534
|
+
name: "fileSize",
|
|
535
|
+
category: "fs",
|
|
536
|
+
compatibility: ["nodejs"],
|
|
537
|
+
fn: fileSize
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
name: "read",
|
|
541
|
+
category: "fs",
|
|
542
|
+
compatibility: ["nodejs"],
|
|
543
|
+
fn: read
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
name: "readdir",
|
|
547
|
+
category: "fs",
|
|
548
|
+
compatibility: ["nodejs"],
|
|
549
|
+
fn: readdir
|
|
550
|
+
}
|
|
551
|
+
];
|
|
453
552
|
|
|
454
|
-
// helpers/
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
code = code.split("`").join("`");
|
|
468
|
-
}
|
|
469
|
-
return utils.block(code, ext).trim() + "\n";
|
|
470
|
-
};
|
|
471
|
-
helpers3.gist = function(id) {
|
|
472
|
-
return utils.tag("script", { src: "https://gist.github.com/" + id + ".js" });
|
|
473
|
-
};
|
|
474
|
-
helpers3.jsfiddle = function jsFiddle(options) {
|
|
475
|
-
var attr = Object.assign({}, options && options.hash);
|
|
476
|
-
if (typeof attr.id === "undefined") {
|
|
477
|
-
throw new Error("jsfiddle helper expects an `id`");
|
|
478
|
-
}
|
|
479
|
-
attr.id = "http://jsfiddle.net/" + attr.id;
|
|
480
|
-
attr.width = attr.width || "100%";
|
|
481
|
-
attr.height = attr.height || "300";
|
|
482
|
-
attr.skin = attr.skin || "/presentation/";
|
|
483
|
-
attr.tabs = (attr.tabs || "result,js,html,css") + attr.skin;
|
|
484
|
-
attr.src = attr.id + "/embedded/" + attr.tabs;
|
|
485
|
-
attr.allowfullscreen = attr.allowfullscreen || "allowfullscreen";
|
|
486
|
-
attr.frameborder = attr.frameborder || "0";
|
|
487
|
-
delete attr.tabs;
|
|
488
|
-
delete attr.skin;
|
|
489
|
-
delete attr.id;
|
|
490
|
-
return utils.tag("iframe", attr);
|
|
491
|
-
};
|
|
553
|
+
// src/helpers/html.ts
|
|
554
|
+
import path3 from "path";
|
|
555
|
+
import tag2 from "html-tag";
|
|
556
|
+
import striptags from "striptags";
|
|
557
|
+
var parseAttributes = (hash = {}) => Object.keys(hash).map((key) => `${key}="${String(hash[key]).replace(/^['"]|["']$/g, "")}"`).join(" ");
|
|
558
|
+
var attr = (options) => {
|
|
559
|
+
const val = parseAttributes(options?.hash ?? {});
|
|
560
|
+
return val.trim() ? ` ${val}` : "";
|
|
561
|
+
};
|
|
562
|
+
var css = function(list, options) {
|
|
563
|
+
if (arguments.length < 2) {
|
|
564
|
+
options = list;
|
|
565
|
+
list = [];
|
|
492
566
|
}
|
|
493
|
-
|
|
567
|
+
let styles = arrayify(list ?? []);
|
|
568
|
+
let assets = "";
|
|
569
|
+
if (this && this.options) {
|
|
570
|
+
assets = this.options.assets || "";
|
|
571
|
+
}
|
|
572
|
+
if (options?.hash?.href) {
|
|
573
|
+
styles = arrayify(options.hash.href);
|
|
574
|
+
}
|
|
575
|
+
return styles.map((item) => {
|
|
576
|
+
const ext = path3.extname(item);
|
|
577
|
+
let fp = item;
|
|
578
|
+
if (!/(^\/\/)|(:\/\/)/.test(item)) {
|
|
579
|
+
fp = path3.posix.join(assets, item);
|
|
580
|
+
}
|
|
581
|
+
if (ext === ".less") {
|
|
582
|
+
return `<link type="text/css" rel="stylesheet/less" href="${fp}">`;
|
|
583
|
+
}
|
|
584
|
+
return `<link type="text/css" rel="stylesheet" href="${fp}">`;
|
|
585
|
+
}).join("\n");
|
|
586
|
+
};
|
|
587
|
+
var js = (context) => {
|
|
588
|
+
if (context && typeof context === "object" && !Array.isArray(context)) {
|
|
589
|
+
const attrStr = parseAttributes(context.hash ?? {});
|
|
590
|
+
return `<script${attrStr ? ` ${attrStr}` : ""}></script>`;
|
|
591
|
+
}
|
|
592
|
+
if (typeof context === "string") {
|
|
593
|
+
return `<script src="${context}"></script>`;
|
|
594
|
+
}
|
|
595
|
+
const items = arrayify(context);
|
|
596
|
+
return items.map(
|
|
597
|
+
(fp) => path3.extname(fp) === ".coffee" ? tag2("script", { type: "text/coffeescript", src: fp }) : tag2("script", { src: fp })
|
|
598
|
+
).join("\n");
|
|
599
|
+
};
|
|
600
|
+
var sanitize = (str) => {
|
|
601
|
+
if (typeof str !== "string") return "";
|
|
602
|
+
return striptags(str).trim();
|
|
603
|
+
};
|
|
604
|
+
var ul = (context, options) => {
|
|
605
|
+
const attrs = parseAttributes(options.hash ?? {});
|
|
606
|
+
const items = context.map(
|
|
607
|
+
(item) => typeof item === "string" ? item : options.fn(item)
|
|
608
|
+
);
|
|
609
|
+
const open = attrs ? `<ul ${attrs}>` : "<ul>";
|
|
610
|
+
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ul>`;
|
|
611
|
+
};
|
|
612
|
+
var ol = (context, options) => {
|
|
613
|
+
const attrs = parseAttributes(options.hash ?? {});
|
|
614
|
+
const items = context.map(
|
|
615
|
+
(item) => typeof item === "string" ? item : options.fn(item)
|
|
616
|
+
);
|
|
617
|
+
const open = attrs ? `<ol ${attrs}>` : "<ol>";
|
|
618
|
+
return `${open}${items.map((i) => `<li>${i}</li>`).join("\n")}</ol>`;
|
|
619
|
+
};
|
|
620
|
+
var thumbnailImage = (context) => {
|
|
621
|
+
let figure = "";
|
|
622
|
+
let image = "";
|
|
623
|
+
const link = context.full || false;
|
|
624
|
+
const imageAttributes = {
|
|
625
|
+
alt: context.alt,
|
|
626
|
+
src: context.thumbnail,
|
|
627
|
+
width: context.size.width,
|
|
628
|
+
height: context.size.height
|
|
629
|
+
};
|
|
630
|
+
const figureAttributes = { id: `image-${context.id}` };
|
|
631
|
+
const linkAttributes = { href: link, rel: "thumbnail" };
|
|
632
|
+
if (context.classes) {
|
|
633
|
+
if (context.classes.image) {
|
|
634
|
+
imageAttributes.class = context.classes.image.join(" ");
|
|
635
|
+
}
|
|
636
|
+
if (context.classes.figure) {
|
|
637
|
+
figureAttributes.class = context.classes.figure.join(" ");
|
|
638
|
+
}
|
|
639
|
+
if (context.classes.link) {
|
|
640
|
+
linkAttributes.class = context.classes.link.join(" ");
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
figure += `<figure ${parseAttributes(figureAttributes)}>
|
|
644
|
+
`;
|
|
645
|
+
image += `<img ${parseAttributes(imageAttributes)}>
|
|
646
|
+
`;
|
|
647
|
+
if (link) {
|
|
648
|
+
figure += `<a ${parseAttributes(linkAttributes)}>
|
|
649
|
+
${image}</a>
|
|
650
|
+
`;
|
|
651
|
+
} else {
|
|
652
|
+
figure += image;
|
|
653
|
+
}
|
|
654
|
+
if (context.caption) {
|
|
655
|
+
figure += `<figcaption>${context.caption}</figcaption>
|
|
656
|
+
`;
|
|
657
|
+
}
|
|
658
|
+
figure += "</figure>";
|
|
659
|
+
return figure;
|
|
660
|
+
};
|
|
661
|
+
var helpers7 = [
|
|
662
|
+
{
|
|
663
|
+
name: "attr",
|
|
664
|
+
category: "html",
|
|
665
|
+
compatibility: ["browser", "nodejs"],
|
|
666
|
+
fn: attr
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
name: "css",
|
|
670
|
+
category: "html",
|
|
671
|
+
compatibility: ["nodejs"],
|
|
672
|
+
fn: css
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
name: "js",
|
|
676
|
+
category: "html",
|
|
677
|
+
compatibility: ["nodejs"],
|
|
678
|
+
fn: js
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
name: "sanitize",
|
|
682
|
+
category: "html",
|
|
683
|
+
compatibility: ["browser", "nodejs"],
|
|
684
|
+
fn: sanitize
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
name: "ul",
|
|
688
|
+
category: "html",
|
|
689
|
+
compatibility: ["browser", "nodejs"],
|
|
690
|
+
fn: ul
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
name: "ol",
|
|
694
|
+
category: "html",
|
|
695
|
+
compatibility: ["browser", "nodejs"],
|
|
696
|
+
fn: ol
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "thumbnailImage",
|
|
700
|
+
category: "html",
|
|
701
|
+
compatibility: ["browser", "nodejs"],
|
|
702
|
+
fn: thumbnailImage
|
|
703
|
+
}
|
|
704
|
+
];
|
|
494
705
|
|
|
495
|
-
// helpers/
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
var array = require_array();
|
|
502
|
-
var utils = require_utils2();
|
|
503
|
-
var helpers3 = module2.exports;
|
|
504
|
-
helpers3.extend = function() {
|
|
505
|
-
var args = [].slice.call(arguments);
|
|
506
|
-
var opts = {};
|
|
507
|
-
if (util.isOptions(args[args.length - 1])) {
|
|
508
|
-
opts = args.pop().hash;
|
|
509
|
-
args.push(opts);
|
|
510
|
-
}
|
|
511
|
-
var context = {};
|
|
512
|
-
for (var i = 0; i < args.length; i++) {
|
|
513
|
-
var obj = args[i];
|
|
514
|
-
if (util.isObject(obj)) {
|
|
515
|
-
var keys = Object.keys(obj);
|
|
516
|
-
for (var j = 0; j < keys.length; j++) {
|
|
517
|
-
var key = keys[j];
|
|
518
|
-
context[key] = obj[key];
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return context;
|
|
523
|
-
};
|
|
524
|
-
helpers3.forIn = function(obj, options) {
|
|
525
|
-
if (!util.isOptions(options)) {
|
|
526
|
-
return obj.inverse(this);
|
|
527
|
-
}
|
|
528
|
-
var data = utils.createFrame(options, options.hash);
|
|
529
|
-
var result = "";
|
|
530
|
-
for (var key in obj) {
|
|
531
|
-
data.key = key;
|
|
532
|
-
result += options.fn(obj[key], { data });
|
|
533
|
-
}
|
|
534
|
-
return result;
|
|
535
|
-
};
|
|
536
|
-
helpers3.forOwn = function(obj, options) {
|
|
537
|
-
if (!util.isOptions(options)) {
|
|
538
|
-
return obj.inverse(this);
|
|
539
|
-
}
|
|
540
|
-
var data = utils.createFrame(options, options.hash);
|
|
541
|
-
var result = "";
|
|
542
|
-
for (var key in obj) {
|
|
543
|
-
if (obj.hasOwnProperty(key)) {
|
|
544
|
-
data.key = key;
|
|
545
|
-
result += options.fn(obj[key], { data });
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return result;
|
|
549
|
-
};
|
|
550
|
-
helpers3.toPath = function() {
|
|
551
|
-
var prop = [];
|
|
552
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
553
|
-
if (typeof arguments[i] === "string" || typeof arguments[i] === "number") {
|
|
554
|
-
prop.push(arguments[i]);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return prop.join(".");
|
|
558
|
-
};
|
|
559
|
-
helpers3.get = function(prop, context, options) {
|
|
560
|
-
var val = utils.get(context, prop);
|
|
561
|
-
if (options && options.fn) {
|
|
562
|
-
return val ? options.fn(val) : options.inverse(context);
|
|
563
|
-
}
|
|
564
|
-
return val;
|
|
565
|
-
};
|
|
566
|
-
helpers3.getObject = function(prop, context) {
|
|
567
|
-
return utils.getObject(context, prop);
|
|
568
|
-
};
|
|
569
|
-
helpers3.hasOwn = function(context, key) {
|
|
570
|
-
return hasOwn.call(context, key);
|
|
571
|
-
};
|
|
572
|
-
helpers3.isObject = function(value) {
|
|
573
|
-
return utils.typeOf(value) === "object";
|
|
574
|
-
};
|
|
575
|
-
helpers3.JSONparse = function(str, options) {
|
|
576
|
-
return JSON.parse(str);
|
|
577
|
-
};
|
|
578
|
-
helpers3.JSONstringify = function(obj, indent) {
|
|
579
|
-
if (!utils.isNumber(indent)) {
|
|
580
|
-
indent = 0;
|
|
581
|
-
}
|
|
582
|
-
return JSON.stringify(obj, null, indent);
|
|
583
|
-
};
|
|
584
|
-
helpers3.merge = function(context) {
|
|
585
|
-
var args = [].slice.call(arguments);
|
|
586
|
-
var opts = {};
|
|
587
|
-
if (util.isOptions(args[args.length - 1])) {
|
|
588
|
-
opts = args.pop().hash;
|
|
589
|
-
args.push(opts);
|
|
590
|
-
}
|
|
591
|
-
return Object.assign.apply(null, args);
|
|
592
|
-
};
|
|
593
|
-
helpers3.parseJSON = helpers3.JSONparse;
|
|
594
|
-
helpers3.pick = function(props, context, options) {
|
|
595
|
-
var keys = array.arrayify(props);
|
|
596
|
-
var len = keys.length, i = -1;
|
|
597
|
-
var result = {};
|
|
598
|
-
while (++i < len) {
|
|
599
|
-
result = helpers3.extend({}, result, utils.getObject(context, keys[i]));
|
|
600
|
-
}
|
|
601
|
-
if (options.fn) {
|
|
602
|
-
if (Object.keys(result).length) {
|
|
603
|
-
return options.fn(result);
|
|
604
|
-
}
|
|
605
|
-
return options.inverse(context);
|
|
606
|
-
}
|
|
607
|
-
return result;
|
|
608
|
-
};
|
|
609
|
-
helpers3.stringify = helpers3.JSONstringify;
|
|
706
|
+
// src/helpers/i18n.ts
|
|
707
|
+
import get from "get-value";
|
|
708
|
+
var i18n = function(prop, locals, options) {
|
|
709
|
+
if (locals && typeof locals === "object" && "hash" in locals && options === void 0) {
|
|
710
|
+
options = locals;
|
|
711
|
+
locals = {};
|
|
610
712
|
}
|
|
611
|
-
|
|
713
|
+
if (typeof prop !== "string") {
|
|
714
|
+
throw new Error('{{i18n}} helper expected "key" to be a string');
|
|
715
|
+
}
|
|
716
|
+
const context = {
|
|
717
|
+
...this,
|
|
718
|
+
...locals,
|
|
719
|
+
...options?.hash ?? {}
|
|
720
|
+
};
|
|
721
|
+
const lang = context.language || context.lang;
|
|
722
|
+
if (typeof lang !== "string") {
|
|
723
|
+
throw new TypeError('{{i18n}} helper expected "language" to be a string');
|
|
724
|
+
}
|
|
725
|
+
const cache = context[lang];
|
|
726
|
+
if (typeof cache === "undefined") {
|
|
727
|
+
throw new Error(`{{i18n}} helper cannot find language "${lang}"`);
|
|
728
|
+
}
|
|
729
|
+
const result = get(cache, prop);
|
|
730
|
+
if (typeof result === "undefined") {
|
|
731
|
+
throw new Error(
|
|
732
|
+
'{{i18n}} helper cannot find property "' + String(prop) + '" for language "' + lang + '"'
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
return String(result);
|
|
736
|
+
};
|
|
737
|
+
var helpers8 = [
|
|
738
|
+
{
|
|
739
|
+
name: "i18n",
|
|
740
|
+
category: "i18n",
|
|
741
|
+
compatibility: ["browser", "nodejs"],
|
|
742
|
+
fn: i18n
|
|
743
|
+
}
|
|
744
|
+
];
|
|
745
|
+
|
|
746
|
+
// src/helpers/inflection.ts
|
|
747
|
+
var inflect = (count, singular, plural, includeCount) => {
|
|
748
|
+
const word = count > 1 || count === 0 ? plural : singular;
|
|
749
|
+
return includeCount ? `${count} ${word}` : word;
|
|
750
|
+
};
|
|
751
|
+
var ordinalize = (value) => {
|
|
752
|
+
const num = Math.abs(Math.round(Number(value)));
|
|
753
|
+
const str = String(value);
|
|
754
|
+
const res = num % 100;
|
|
755
|
+
if ([11, 12, 13].includes(res)) {
|
|
756
|
+
return `${str}th`;
|
|
757
|
+
}
|
|
758
|
+
switch (num % 10) {
|
|
759
|
+
case 1:
|
|
760
|
+
return `${str}st`;
|
|
761
|
+
case 2:
|
|
762
|
+
return `${str}nd`;
|
|
763
|
+
case 3:
|
|
764
|
+
return `${str}rd`;
|
|
765
|
+
default:
|
|
766
|
+
return `${str}th`;
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
var helpers9 = [
|
|
770
|
+
{
|
|
771
|
+
name: "inflect",
|
|
772
|
+
category: "inflection",
|
|
773
|
+
compatibility: ["browser", "nodejs"],
|
|
774
|
+
fn: inflect
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
name: "ordinalize",
|
|
778
|
+
category: "inflection",
|
|
779
|
+
compatibility: ["browser", "nodejs"],
|
|
780
|
+
fn: ordinalize
|
|
781
|
+
}
|
|
782
|
+
];
|
|
783
|
+
|
|
784
|
+
// src/helpers/logging.ts
|
|
785
|
+
import loggingHelpers from "logging-helpers";
|
|
786
|
+
var {
|
|
787
|
+
log,
|
|
788
|
+
ok,
|
|
789
|
+
success,
|
|
790
|
+
info,
|
|
791
|
+
warning,
|
|
792
|
+
warn,
|
|
793
|
+
error,
|
|
794
|
+
danger,
|
|
795
|
+
bold,
|
|
796
|
+
_debug,
|
|
797
|
+
_inspect
|
|
798
|
+
} = loggingHelpers;
|
|
799
|
+
var helpers10 = [
|
|
800
|
+
{
|
|
801
|
+
name: "log",
|
|
802
|
+
category: "logging",
|
|
803
|
+
compatibility: ["nodejs"],
|
|
804
|
+
fn: log
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "ok",
|
|
808
|
+
category: "logging",
|
|
809
|
+
compatibility: ["nodejs"],
|
|
810
|
+
fn: ok
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
name: "success",
|
|
814
|
+
category: "logging",
|
|
815
|
+
compatibility: ["nodejs"],
|
|
816
|
+
fn: success
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
name: "info",
|
|
820
|
+
category: "logging",
|
|
821
|
+
compatibility: ["nodejs"],
|
|
822
|
+
fn: info
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
name: "warning",
|
|
826
|
+
category: "logging",
|
|
827
|
+
compatibility: ["nodejs"],
|
|
828
|
+
fn: warning
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
name: "warn",
|
|
832
|
+
category: "logging",
|
|
833
|
+
compatibility: ["nodejs"],
|
|
834
|
+
fn: warn
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
name: "error",
|
|
838
|
+
category: "logging",
|
|
839
|
+
compatibility: ["nodejs"],
|
|
840
|
+
fn: error
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
name: "danger",
|
|
844
|
+
category: "logging",
|
|
845
|
+
compatibility: ["nodejs"],
|
|
846
|
+
fn: danger
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
name: "bold",
|
|
850
|
+
category: "logging",
|
|
851
|
+
compatibility: ["nodejs"],
|
|
852
|
+
fn: bold
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
name: "_debug",
|
|
856
|
+
category: "logging",
|
|
857
|
+
compatibility: ["nodejs"],
|
|
858
|
+
fn: _debug
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
name: "_inspect",
|
|
862
|
+
category: "logging",
|
|
863
|
+
compatibility: ["nodejs"],
|
|
864
|
+
fn: _inspect
|
|
865
|
+
}
|
|
866
|
+
];
|
|
612
867
|
|
|
613
|
-
// helpers/
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
868
|
+
// src/helpers/match.ts
|
|
869
|
+
import micromatch2 from "micromatch";
|
|
870
|
+
var match = (files, patterns, options) => {
|
|
871
|
+
const pats = typeof patterns === "string" ? patterns.split(/, */) : patterns;
|
|
872
|
+
return micromatch2(files, pats, options);
|
|
873
|
+
};
|
|
874
|
+
var isMatch = (filepath, pattern, options) => {
|
|
875
|
+
return micromatch2.isMatch(filepath, pattern, options);
|
|
876
|
+
};
|
|
877
|
+
var mm = (...args) => {
|
|
878
|
+
console.log("the {{mm}} helper is depcrecated and will be removed");
|
|
879
|
+
console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
|
|
880
|
+
console.log("helper instead.");
|
|
881
|
+
return match(...args);
|
|
882
|
+
};
|
|
883
|
+
var helpers11 = [
|
|
884
|
+
{
|
|
885
|
+
name: "match",
|
|
886
|
+
category: "match",
|
|
887
|
+
compatibility: ["browser", "nodejs"],
|
|
888
|
+
fn: match
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
name: "isMatch",
|
|
892
|
+
category: "match",
|
|
893
|
+
compatibility: ["browser", "nodejs"],
|
|
894
|
+
fn: isMatch
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
name: "mm",
|
|
898
|
+
category: "match",
|
|
899
|
+
compatibility: ["browser", "nodejs"],
|
|
900
|
+
fn: mm
|
|
901
|
+
}
|
|
902
|
+
];
|
|
903
|
+
|
|
904
|
+
// src/helpers/math.ts
|
|
905
|
+
var isNumeric = (value) => typeof value === "number" && !Number.isNaN(value) || typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value));
|
|
906
|
+
var toNumber = (value, message = "expected a number") => {
|
|
907
|
+
if (isNumeric(value)) {
|
|
908
|
+
return Number(value);
|
|
909
|
+
}
|
|
910
|
+
throw new TypeError(message);
|
|
911
|
+
};
|
|
912
|
+
var abs = (value) => {
|
|
913
|
+
const num = toNumber(value);
|
|
914
|
+
return Math.abs(num);
|
|
915
|
+
};
|
|
916
|
+
var add = (a, b) => {
|
|
917
|
+
if (isNumeric(a) && isNumeric(b)) {
|
|
918
|
+
return Number(a) + Number(b);
|
|
919
|
+
}
|
|
920
|
+
return "";
|
|
921
|
+
};
|
|
922
|
+
var avg = (...values) => {
|
|
923
|
+
const flat = values.flat().map((n) => Number(n));
|
|
924
|
+
return sum(flat) / flat.length;
|
|
925
|
+
};
|
|
926
|
+
var ceil = (value) => {
|
|
927
|
+
const num = toNumber(value);
|
|
928
|
+
return Math.ceil(num);
|
|
929
|
+
};
|
|
930
|
+
var divide = (a, b) => {
|
|
931
|
+
const numA = toNumber(a, "expected the first argument to be a number");
|
|
932
|
+
const numB = toNumber(b, "expected the second argument to be a number");
|
|
933
|
+
return numA / numB;
|
|
934
|
+
};
|
|
935
|
+
var floor = (value) => {
|
|
936
|
+
const num = toNumber(value);
|
|
937
|
+
return Math.floor(num);
|
|
938
|
+
};
|
|
939
|
+
var minus = (a, b) => {
|
|
940
|
+
const numA = toNumber(a, "expected the first argument to be a number");
|
|
941
|
+
const numB = toNumber(b, "expected the second argument to be a number");
|
|
942
|
+
return numA - numB;
|
|
943
|
+
};
|
|
944
|
+
var modulo = (a, b) => {
|
|
945
|
+
const numA = toNumber(a, "expected the first argument to be a number");
|
|
946
|
+
const numB = toNumber(b, "expected the second argument to be a number");
|
|
947
|
+
return numA % numB;
|
|
948
|
+
};
|
|
949
|
+
var multiply = (a, b) => {
|
|
950
|
+
const numA = toNumber(a, "expected the first argument to be a number");
|
|
951
|
+
const numB = toNumber(b, "expected the second argument to be a number");
|
|
952
|
+
return numA * numB;
|
|
953
|
+
};
|
|
954
|
+
var plus = (a, b) => {
|
|
955
|
+
const numA = toNumber(a, "expected the first argument to be a number");
|
|
956
|
+
const numB = toNumber(b, "expected the second argument to be a number");
|
|
957
|
+
return numA + numB;
|
|
958
|
+
};
|
|
959
|
+
var random = (min, max) => {
|
|
960
|
+
const minNum = toNumber(min, "expected minimum to be a number");
|
|
961
|
+
const maxNum = toNumber(max, "expected maximum to be a number");
|
|
962
|
+
return minNum + Math.floor(Math.random() * (maxNum - minNum + 1));
|
|
963
|
+
};
|
|
964
|
+
var remainder = (a, b) => a % b;
|
|
965
|
+
var round = (value) => {
|
|
966
|
+
const num = toNumber(value);
|
|
967
|
+
return Math.round(num);
|
|
968
|
+
};
|
|
969
|
+
var subtract = (a, b) => {
|
|
970
|
+
const numA = toNumber(a, "expected the first argument to be a number");
|
|
971
|
+
const numB = toNumber(b, "expected the second argument to be a number");
|
|
972
|
+
return numA - numB;
|
|
973
|
+
};
|
|
974
|
+
var sum = (...values) => {
|
|
975
|
+
const flat = values.flat();
|
|
976
|
+
let total = 0;
|
|
977
|
+
for (const value of flat) {
|
|
978
|
+
if (isNumeric(value)) {
|
|
979
|
+
total += Number(value);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return total;
|
|
983
|
+
};
|
|
984
|
+
var times = (a, b) => multiply(a, b);
|
|
985
|
+
var helpers12 = [
|
|
986
|
+
{
|
|
987
|
+
name: "abs",
|
|
988
|
+
category: "math",
|
|
989
|
+
compatibility: ["browser", "nodejs"],
|
|
990
|
+
fn: abs
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
name: "add",
|
|
994
|
+
category: "math",
|
|
995
|
+
compatibility: ["browser", "nodejs"],
|
|
996
|
+
fn: add
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
name: "avg",
|
|
1000
|
+
category: "math",
|
|
1001
|
+
compatibility: ["browser", "nodejs"],
|
|
1002
|
+
fn: avg
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
name: "ceil",
|
|
1006
|
+
category: "math",
|
|
1007
|
+
compatibility: ["browser", "nodejs"],
|
|
1008
|
+
fn: ceil
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
name: "divide",
|
|
1012
|
+
category: "math",
|
|
1013
|
+
compatibility: ["browser", "nodejs"],
|
|
1014
|
+
fn: divide
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
name: "floor",
|
|
1018
|
+
category: "math",
|
|
1019
|
+
compatibility: ["browser", "nodejs"],
|
|
1020
|
+
fn: floor
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
name: "minus",
|
|
1024
|
+
category: "math",
|
|
1025
|
+
compatibility: ["browser", "nodejs"],
|
|
1026
|
+
fn: minus
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
name: "modulo",
|
|
1030
|
+
category: "math",
|
|
1031
|
+
compatibility: ["browser", "nodejs"],
|
|
1032
|
+
fn: modulo
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
name: "multiply",
|
|
1036
|
+
category: "math",
|
|
1037
|
+
compatibility: ["browser", "nodejs"],
|
|
1038
|
+
fn: multiply
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
name: "plus",
|
|
1042
|
+
category: "math",
|
|
1043
|
+
compatibility: ["browser", "nodejs"],
|
|
1044
|
+
fn: plus
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
name: "random",
|
|
1048
|
+
category: "math",
|
|
1049
|
+
compatibility: ["browser", "nodejs"],
|
|
1050
|
+
fn: random
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
name: "remainder",
|
|
1054
|
+
category: "math",
|
|
1055
|
+
compatibility: ["browser", "nodejs"],
|
|
1056
|
+
fn: remainder
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
name: "round",
|
|
1060
|
+
category: "math",
|
|
1061
|
+
compatibility: ["browser", "nodejs"],
|
|
1062
|
+
fn: round
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
name: "subtract",
|
|
1066
|
+
category: "math",
|
|
1067
|
+
compatibility: ["browser", "nodejs"],
|
|
1068
|
+
fn: subtract
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
name: "sum",
|
|
1072
|
+
category: "math",
|
|
1073
|
+
compatibility: ["browser", "nodejs"],
|
|
1074
|
+
fn: sum
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
name: "times",
|
|
1078
|
+
category: "math",
|
|
1079
|
+
compatibility: ["browser", "nodejs"],
|
|
1080
|
+
fn: times
|
|
1081
|
+
}
|
|
1082
|
+
];
|
|
1083
|
+
|
|
1084
|
+
// src/helpers/md.ts
|
|
1085
|
+
import fs3 from "fs";
|
|
1086
|
+
import path4 from "path";
|
|
1087
|
+
import process2 from "process";
|
|
1088
|
+
import ent from "ent";
|
|
1089
|
+
import Handlebars from "handlebars";
|
|
1090
|
+
import { Remarkable } from "remarkable";
|
|
1091
|
+
var renderMarkdown = (input, options = {}) => {
|
|
1092
|
+
const options_ = { cwd: process2.cwd(), ...options };
|
|
1093
|
+
const md = new Remarkable({
|
|
1094
|
+
breaks: true,
|
|
1095
|
+
html: true,
|
|
1096
|
+
langPrefix: "lang-",
|
|
1097
|
+
typographer: false,
|
|
1098
|
+
xhtmlOut: false
|
|
1099
|
+
});
|
|
1100
|
+
const filepath = path4.resolve(options_.cwd, input);
|
|
1101
|
+
let string_ = input;
|
|
1102
|
+
if (fs3.existsSync(filepath)) {
|
|
1103
|
+
string_ = fs3.readFileSync(filepath, "utf8");
|
|
1104
|
+
}
|
|
1105
|
+
return new Handlebars.SafeString(ent.decode(md.render(string_)));
|
|
1106
|
+
};
|
|
1107
|
+
var helpers13 = [
|
|
1108
|
+
{
|
|
1109
|
+
name: "md",
|
|
1110
|
+
category: "markdown",
|
|
1111
|
+
compatibility: ["nodejs"],
|
|
1112
|
+
fn: renderMarkdown
|
|
1113
|
+
}
|
|
1114
|
+
];
|
|
1115
|
+
|
|
1116
|
+
// src/helpers/misc.ts
|
|
1117
|
+
import get2 from "get-value";
|
|
1118
|
+
import createFrame from "handlebars-helper-create-frame";
|
|
1119
|
+
import util from "handlebars-utils";
|
|
1120
|
+
import kindOf from "kind-of";
|
|
1121
|
+
var frame = createFrame;
|
|
1122
|
+
function option(prop, locals, options) {
|
|
1123
|
+
return get2(util.options(this, locals, options), prop);
|
|
1124
|
+
}
|
|
1125
|
+
function noop(options) {
|
|
1126
|
+
return options.fn(this);
|
|
1127
|
+
}
|
|
1128
|
+
var typeOf = kindOf;
|
|
1129
|
+
function withHash(options) {
|
|
1130
|
+
if (options.hash && Object.keys(options.hash).length) {
|
|
1131
|
+
return options.fn(options.hash);
|
|
1132
|
+
}
|
|
1133
|
+
return options.inverse(this);
|
|
1134
|
+
}
|
|
1135
|
+
var helpers14 = [
|
|
1136
|
+
{
|
|
1137
|
+
name: "frame",
|
|
1138
|
+
category: "misc",
|
|
1139
|
+
compatibility: ["browser", "nodejs"],
|
|
1140
|
+
fn: frame
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
name: "option",
|
|
1144
|
+
category: "misc",
|
|
1145
|
+
compatibility: ["browser", "nodejs"],
|
|
1146
|
+
fn: option
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
name: "noop",
|
|
1150
|
+
category: "misc",
|
|
1151
|
+
compatibility: ["browser", "nodejs"],
|
|
1152
|
+
fn: noop
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
name: "typeOf",
|
|
1156
|
+
category: "misc",
|
|
1157
|
+
compatibility: ["browser", "nodejs"],
|
|
1158
|
+
fn: typeOf
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
name: "withHash",
|
|
1162
|
+
category: "misc",
|
|
1163
|
+
compatibility: ["browser", "nodejs"],
|
|
1164
|
+
fn: withHash
|
|
1165
|
+
}
|
|
1166
|
+
];
|
|
1167
|
+
|
|
1168
|
+
// src/helpers/number.ts
|
|
1169
|
+
var isNumeric2 = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
1170
|
+
var bytes = (value, precision) => {
|
|
1171
|
+
if (value == null) return "0 B";
|
|
1172
|
+
let num;
|
|
1173
|
+
if (typeof value === "string") {
|
|
1174
|
+
num = value.length;
|
|
1175
|
+
if (!num) return "0 B";
|
|
1176
|
+
} else if (isNumeric2(value)) {
|
|
1177
|
+
num = Number(value);
|
|
1178
|
+
} else if (typeof value.length === "number") {
|
|
1179
|
+
num = value.length;
|
|
1180
|
+
if (!num) return "0 B";
|
|
1181
|
+
} else {
|
|
1182
|
+
return "0 B";
|
|
1183
|
+
}
|
|
1184
|
+
const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
|
|
1185
|
+
const abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
1186
|
+
const factor = 10 ** prec;
|
|
1187
|
+
for (let i = abbr.length - 1; i >= 0; i--) {
|
|
1188
|
+
const size = 10 ** (i * 3);
|
|
1189
|
+
if (size <= num + 1) {
|
|
1190
|
+
const val = Math.round(num * factor / size) / factor;
|
|
1191
|
+
return `${val} ${abbr[i]}`;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
return `${num}`;
|
|
1195
|
+
};
|
|
1196
|
+
var addCommas = (num) => num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
|
1197
|
+
var phoneNumber = (num) => {
|
|
1198
|
+
const str = num.toString();
|
|
1199
|
+
return `(${str.substr(0, 3)}) ${str.substr(3, 3)}-${str.substr(6, 4)}`;
|
|
1200
|
+
};
|
|
1201
|
+
var toAbbr = (value, precision) => {
|
|
1202
|
+
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1203
|
+
const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 2;
|
|
1204
|
+
const factor = 10 ** prec;
|
|
1205
|
+
const abbr = ["k", "m", "b", "t", "q"];
|
|
1206
|
+
for (let i = abbr.length - 1; i >= 0; i--) {
|
|
1207
|
+
const size = 10 ** ((i + 1) * 3);
|
|
1208
|
+
if (size <= num + 1) {
|
|
1209
|
+
const val = Math.round(num * factor / size) / factor;
|
|
1210
|
+
return `${val}${abbr[i]}`;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
return `${num}`;
|
|
1214
|
+
};
|
|
1215
|
+
var toExponential = (value, digits) => {
|
|
1216
|
+
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1217
|
+
const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
|
|
1218
|
+
return Number(num).toExponential(d);
|
|
1219
|
+
};
|
|
1220
|
+
var toFixed = (value, digits) => {
|
|
1221
|
+
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1222
|
+
const d = typeof digits === "number" && !Number.isNaN(digits) ? digits : 0;
|
|
1223
|
+
return Number(num).toFixed(d);
|
|
1224
|
+
};
|
|
1225
|
+
var toFloat = (value) => parseFloat(String(value));
|
|
1226
|
+
var toInt = (value) => parseInt(String(value), 10);
|
|
1227
|
+
var toPrecision = (value, precision) => {
|
|
1228
|
+
const num = isNumeric2(value) ? Number(value) : 0;
|
|
1229
|
+
const prec = typeof precision === "number" && !Number.isNaN(precision) ? precision : 1;
|
|
1230
|
+
return Number(num).toPrecision(prec);
|
|
1231
|
+
};
|
|
1232
|
+
var helpers15 = [
|
|
1233
|
+
{
|
|
1234
|
+
name: "bytes",
|
|
1235
|
+
category: "number",
|
|
1236
|
+
compatibility: ["browser", "nodejs"],
|
|
1237
|
+
fn: bytes
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: "addCommas",
|
|
1241
|
+
category: "number",
|
|
1242
|
+
compatibility: ["browser", "nodejs"],
|
|
1243
|
+
fn: addCommas
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: "phoneNumber",
|
|
1247
|
+
category: "number",
|
|
1248
|
+
compatibility: ["browser", "nodejs"],
|
|
1249
|
+
fn: phoneNumber
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
name: "toAbbr",
|
|
1253
|
+
category: "number",
|
|
1254
|
+
compatibility: ["browser", "nodejs"],
|
|
1255
|
+
fn: toAbbr
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
name: "toExponential",
|
|
1259
|
+
category: "number",
|
|
1260
|
+
compatibility: ["browser", "nodejs"],
|
|
1261
|
+
fn: toExponential
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
name: "toFixed",
|
|
1265
|
+
category: "number",
|
|
1266
|
+
compatibility: ["browser", "nodejs"],
|
|
1267
|
+
fn: toFixed
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
name: "toFloat",
|
|
1271
|
+
category: "number",
|
|
1272
|
+
compatibility: ["browser", "nodejs"],
|
|
1273
|
+
fn: toFloat
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
name: "toInt",
|
|
1277
|
+
category: "number",
|
|
1278
|
+
compatibility: ["browser", "nodejs"],
|
|
1279
|
+
fn: toInt
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
name: "toPrecision",
|
|
1283
|
+
category: "number",
|
|
1284
|
+
compatibility: ["browser", "nodejs"],
|
|
1285
|
+
fn: toPrecision
|
|
1286
|
+
}
|
|
1287
|
+
];
|
|
1288
|
+
|
|
1289
|
+
// src/helpers/object.ts
|
|
1290
|
+
import getObject from "get-object";
|
|
1291
|
+
import get3 from "get-value";
|
|
1292
|
+
var isOptions2 = (value) => {
|
|
1293
|
+
return Boolean(value && typeof value === "object" && "hash" in value);
|
|
1294
|
+
};
|
|
1295
|
+
var createFrame2 = (options, hash) => ({
|
|
1296
|
+
...options?.data || {},
|
|
1297
|
+
...hash
|
|
1298
|
+
});
|
|
1299
|
+
var extend = (...objects) => {
|
|
1300
|
+
const args = [...objects];
|
|
1301
|
+
if (args.length && isOptions2(args[args.length - 1])) {
|
|
1302
|
+
const opts = args.pop();
|
|
1303
|
+
args.push(opts.hash);
|
|
1304
|
+
}
|
|
1305
|
+
const result = {};
|
|
1306
|
+
for (const obj of args) {
|
|
1307
|
+
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
1308
|
+
Object.assign(result, obj);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
return result;
|
|
1312
|
+
};
|
|
1313
|
+
var forIn = (obj, options) => {
|
|
1314
|
+
if (!isOptions2(options)) {
|
|
1315
|
+
return options?.inverse?.(obj) ?? "";
|
|
1316
|
+
}
|
|
1317
|
+
const data = createFrame2(options, options.hash || {});
|
|
1318
|
+
let result = "";
|
|
1319
|
+
for (const key in obj) {
|
|
1320
|
+
data.key = key;
|
|
1321
|
+
result += options.fn(obj[key], { data });
|
|
1322
|
+
}
|
|
1323
|
+
return result;
|
|
1324
|
+
};
|
|
1325
|
+
var forOwn = (obj, options) => {
|
|
1326
|
+
if (!isOptions2(options)) {
|
|
1327
|
+
return options?.inverse?.(obj) ?? "";
|
|
1328
|
+
}
|
|
1329
|
+
const data = createFrame2(options, options.hash || {});
|
|
1330
|
+
let result = "";
|
|
1331
|
+
for (const key in obj) {
|
|
1332
|
+
if (Object.hasOwn(obj, key)) {
|
|
1333
|
+
data.key = key;
|
|
1334
|
+
result += options.fn(obj[key], { data });
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
return result;
|
|
1338
|
+
};
|
|
1339
|
+
var toPath = (...prop) => {
|
|
1340
|
+
const parts = [];
|
|
1341
|
+
for (const p of prop) {
|
|
1342
|
+
if (typeof p === "string" || typeof p === "number") {
|
|
1343
|
+
parts.push(p);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
return parts.join(".");
|
|
1347
|
+
};
|
|
1348
|
+
var getHelper = (prop, context, options) => {
|
|
1349
|
+
const val = get3(context, prop);
|
|
1350
|
+
if (options && typeof options.fn === "function") {
|
|
1351
|
+
return val ? options.fn(val) : options.inverse?.(context);
|
|
1352
|
+
}
|
|
1353
|
+
return val;
|
|
1354
|
+
};
|
|
1355
|
+
var getObjectHelper = (prop, context) => {
|
|
1356
|
+
return getObject(context, prop);
|
|
1357
|
+
};
|
|
1358
|
+
var hasOwn = (context, key) => {
|
|
1359
|
+
return Object.hasOwn(context, key);
|
|
1360
|
+
};
|
|
1361
|
+
var isObject = (value) => {
|
|
1362
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1363
|
+
};
|
|
1364
|
+
var JSONparse = (str) => {
|
|
1365
|
+
return JSON.parse(str);
|
|
1366
|
+
};
|
|
1367
|
+
var JSONstringify = (obj, indent) => {
|
|
1368
|
+
const ind = typeof indent === "number" ? indent : 0;
|
|
1369
|
+
return JSON.stringify(obj, null, ind);
|
|
1370
|
+
};
|
|
1371
|
+
var merge = (context, ...objects) => {
|
|
1372
|
+
const args = [context, ...objects];
|
|
1373
|
+
if (args.length && isOptions2(args[args.length - 1])) {
|
|
1374
|
+
const opts = args.pop();
|
|
1375
|
+
args.push(opts.hash);
|
|
1376
|
+
}
|
|
1377
|
+
return Object.assign(...args);
|
|
1378
|
+
};
|
|
1379
|
+
var parseJSON = JSONparse;
|
|
1380
|
+
var stringify = JSONstringify;
|
|
1381
|
+
var pick = (props, context, options) => {
|
|
1382
|
+
const keys = arrayify(props);
|
|
1383
|
+
let result = {};
|
|
1384
|
+
for (const key of keys) {
|
|
1385
|
+
result = Object.assign({}, result, getObject(context, key));
|
|
644
1386
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
"use strict";
|
|
651
|
-
var has = require("has-value");
|
|
652
|
-
var util = require("handlebars-utils");
|
|
653
|
-
var utils = require_utils2();
|
|
654
|
-
var helpers3 = module2.exports;
|
|
655
|
-
helpers3.and = function() {
|
|
656
|
-
var len = arguments.length - 1;
|
|
657
|
-
var options = arguments[len];
|
|
658
|
-
var val = true;
|
|
659
|
-
for (var i = 0; i < len; i++) {
|
|
660
|
-
if (!arguments[i]) {
|
|
661
|
-
val = false;
|
|
662
|
-
break;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
return util.value(val, this, options);
|
|
666
|
-
};
|
|
667
|
-
helpers3.compare = function(a, operator, b, options) {
|
|
668
|
-
if (arguments.length < 4) {
|
|
669
|
-
throw new Error("handlebars Helper {{compare}} expects 4 arguments");
|
|
670
|
-
}
|
|
671
|
-
var result;
|
|
672
|
-
switch (operator) {
|
|
673
|
-
case "==":
|
|
674
|
-
result = a == b;
|
|
675
|
-
break;
|
|
676
|
-
case "===":
|
|
677
|
-
result = a === b;
|
|
678
|
-
break;
|
|
679
|
-
case "!=":
|
|
680
|
-
result = a != b;
|
|
681
|
-
break;
|
|
682
|
-
case "!==":
|
|
683
|
-
result = a !== b;
|
|
684
|
-
break;
|
|
685
|
-
case "<":
|
|
686
|
-
result = a < b;
|
|
687
|
-
break;
|
|
688
|
-
case ">":
|
|
689
|
-
result = a > b;
|
|
690
|
-
break;
|
|
691
|
-
case "<=":
|
|
692
|
-
result = a <= b;
|
|
693
|
-
break;
|
|
694
|
-
case ">=":
|
|
695
|
-
result = a >= b;
|
|
696
|
-
break;
|
|
697
|
-
case "typeof":
|
|
698
|
-
result = typeof a === b;
|
|
699
|
-
break;
|
|
700
|
-
default: {
|
|
701
|
-
throw new Error("helper {{compare}}: invalid operator: `" + operator + "`");
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
return util.value(result, this, options);
|
|
705
|
-
};
|
|
706
|
-
helpers3.contains = function(collection, value, startIndex, options) {
|
|
707
|
-
if (typeof startIndex === "object") {
|
|
708
|
-
options = startIndex;
|
|
709
|
-
startIndex = void 0;
|
|
710
|
-
}
|
|
711
|
-
var val = utils.contains(collection, value, startIndex);
|
|
712
|
-
return util.value(val, this, options);
|
|
713
|
-
};
|
|
714
|
-
helpers3.default = function() {
|
|
715
|
-
for (var i = 0; i < arguments.length - 1; i++) {
|
|
716
|
-
if (arguments[i] != null) return arguments[i];
|
|
717
|
-
}
|
|
718
|
-
return "";
|
|
719
|
-
};
|
|
720
|
-
helpers3.eq = function(a, b, options) {
|
|
721
|
-
if (arguments.length === 2) {
|
|
722
|
-
options = b;
|
|
723
|
-
b = options.hash.compare;
|
|
724
|
-
}
|
|
725
|
-
return util.value(a === b, this, options);
|
|
726
|
-
};
|
|
727
|
-
helpers3.gt = function(a, b, options) {
|
|
728
|
-
if (arguments.length === 2) {
|
|
729
|
-
options = b;
|
|
730
|
-
b = options.hash.compare;
|
|
731
|
-
}
|
|
732
|
-
return util.value(a > b, this, options);
|
|
733
|
-
};
|
|
734
|
-
helpers3.gte = function(a, b, options) {
|
|
735
|
-
if (arguments.length === 2) {
|
|
736
|
-
options = b;
|
|
737
|
-
b = options.hash.compare;
|
|
738
|
-
}
|
|
739
|
-
return util.value(a >= b, this, options);
|
|
740
|
-
};
|
|
741
|
-
helpers3.has = function(value, pattern, options) {
|
|
742
|
-
if (util.isOptions(value)) {
|
|
743
|
-
options = value;
|
|
744
|
-
pattern = null;
|
|
745
|
-
value = null;
|
|
746
|
-
}
|
|
747
|
-
if (util.isOptions(pattern)) {
|
|
748
|
-
options = pattern;
|
|
749
|
-
pattern = null;
|
|
750
|
-
}
|
|
751
|
-
if (value === null) {
|
|
752
|
-
return util.value(false, this, options);
|
|
753
|
-
}
|
|
754
|
-
if (arguments.length === 2) {
|
|
755
|
-
return util.value(has(this, value), this, options);
|
|
756
|
-
}
|
|
757
|
-
if ((Array.isArray(value) || util.isString(value)) && util.isString(pattern)) {
|
|
758
|
-
if (value.indexOf(pattern) > -1) {
|
|
759
|
-
return util.fn(true, this, options);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
if (util.isObject(value) && util.isString(pattern) && pattern in value) {
|
|
763
|
-
return util.fn(true, this, options);
|
|
764
|
-
}
|
|
765
|
-
return util.inverse(false, this, options);
|
|
766
|
-
};
|
|
767
|
-
helpers3.isFalsey = function(val, options) {
|
|
768
|
-
return util.value(utils.falsey(val), this, options);
|
|
769
|
-
};
|
|
770
|
-
helpers3.isTruthy = function(val, options) {
|
|
771
|
-
return util.value(!utils.falsey(val), this, options);
|
|
772
|
-
};
|
|
773
|
-
helpers3.ifEven = function(num, options) {
|
|
774
|
-
return util.value(utils.isEven(num), this, options);
|
|
775
|
-
};
|
|
776
|
-
helpers3.ifNth = function(a, b, options) {
|
|
777
|
-
var isNth = utils.isNumber(a) && utils.isNumber(b) && b % a === 0;
|
|
778
|
-
return util.value(isNth, this, options);
|
|
779
|
-
};
|
|
780
|
-
helpers3.ifOdd = function(val, options) {
|
|
781
|
-
return util.value(!utils.isEven(val), this, options);
|
|
782
|
-
};
|
|
783
|
-
helpers3.is = function(a, b, options) {
|
|
784
|
-
if (arguments.length === 2) {
|
|
785
|
-
options = b;
|
|
786
|
-
b = options.hash.compare;
|
|
787
|
-
}
|
|
788
|
-
return util.value(a == b, this, options);
|
|
789
|
-
};
|
|
790
|
-
helpers3.isnt = function(a, b, options) {
|
|
791
|
-
if (arguments.length === 2) {
|
|
792
|
-
options = b;
|
|
793
|
-
b = options.hash.compare;
|
|
794
|
-
}
|
|
795
|
-
return util.value(a != b, this, options);
|
|
796
|
-
};
|
|
797
|
-
helpers3.lt = function(a, b, options) {
|
|
798
|
-
if (arguments.length === 2) {
|
|
799
|
-
options = b;
|
|
800
|
-
b = options.hash.compare;
|
|
801
|
-
}
|
|
802
|
-
return util.value(a < b, this, options);
|
|
803
|
-
};
|
|
804
|
-
helpers3.lte = function(a, b, options) {
|
|
805
|
-
if (arguments.length === 2) {
|
|
806
|
-
options = b;
|
|
807
|
-
b = options.hash.compare;
|
|
808
|
-
}
|
|
809
|
-
return util.value(a <= b, this, options);
|
|
810
|
-
};
|
|
811
|
-
helpers3.neither = function(a, b, options) {
|
|
812
|
-
return util.value(!a && !b, this, options);
|
|
813
|
-
};
|
|
814
|
-
helpers3.not = function(val, options) {
|
|
815
|
-
return util.value(!val, this, options);
|
|
816
|
-
};
|
|
817
|
-
helpers3.or = function() {
|
|
818
|
-
var len = arguments.length - 1;
|
|
819
|
-
var options = arguments[len];
|
|
820
|
-
var val = false;
|
|
821
|
-
for (var i = 0; i < len; i++) {
|
|
822
|
-
if (arguments[i]) {
|
|
823
|
-
val = true;
|
|
824
|
-
break;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
return util.value(val, this, options);
|
|
828
|
-
};
|
|
829
|
-
helpers3.unlessEq = function(a, b, options) {
|
|
830
|
-
if (util.isOptions(b)) {
|
|
831
|
-
options = b;
|
|
832
|
-
b = options.hash.compare;
|
|
833
|
-
}
|
|
834
|
-
return util.value(a !== b, this, options);
|
|
835
|
-
};
|
|
836
|
-
helpers3.unlessGt = function(a, b, options) {
|
|
837
|
-
if (util.isOptions(b)) {
|
|
838
|
-
options = b;
|
|
839
|
-
b = options.hash.compare;
|
|
840
|
-
}
|
|
841
|
-
return util.value(a <= b, this, options);
|
|
842
|
-
};
|
|
843
|
-
helpers3.unlessLt = function(a, b, options) {
|
|
844
|
-
if (util.isOptions(b)) {
|
|
845
|
-
options = b;
|
|
846
|
-
b = options.hash.compare;
|
|
847
|
-
}
|
|
848
|
-
return util.value(a >= b, this, options);
|
|
849
|
-
};
|
|
850
|
-
helpers3.unlessGteq = function(a, b, options) {
|
|
851
|
-
if (util.isOptions(b)) {
|
|
852
|
-
options = b;
|
|
853
|
-
b = options.hash.compare;
|
|
854
|
-
}
|
|
855
|
-
return util.value(a < b, this, options);
|
|
856
|
-
};
|
|
857
|
-
helpers3.unlessLteq = function(a, b, options) {
|
|
858
|
-
if (util.isOptions(b)) {
|
|
859
|
-
options = b;
|
|
860
|
-
b = options.hash.compare;
|
|
861
|
-
}
|
|
862
|
-
return util.value(a > b, this, options);
|
|
863
|
-
};
|
|
1387
|
+
if (options && typeof options.fn === "function") {
|
|
1388
|
+
if (Object.keys(result).length) {
|
|
1389
|
+
return options.fn(result);
|
|
1390
|
+
}
|
|
1391
|
+
return options.inverse?.(context);
|
|
864
1392
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
1393
|
+
return result;
|
|
1394
|
+
};
|
|
1395
|
+
var helpers16 = [
|
|
1396
|
+
{
|
|
1397
|
+
name: "extend",
|
|
1398
|
+
category: "object",
|
|
1399
|
+
compatibility: ["browser", "nodejs"],
|
|
1400
|
+
fn: extend
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
name: "forIn",
|
|
1404
|
+
category: "object",
|
|
1405
|
+
compatibility: ["browser", "nodejs"],
|
|
1406
|
+
fn: forIn
|
|
1407
|
+
},
|
|
1408
|
+
{
|
|
1409
|
+
name: "forOwn",
|
|
1410
|
+
category: "object",
|
|
1411
|
+
compatibility: ["browser", "nodejs"],
|
|
1412
|
+
fn: forOwn
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
name: "toPath",
|
|
1416
|
+
category: "object",
|
|
1417
|
+
compatibility: ["browser", "nodejs"],
|
|
1418
|
+
fn: toPath
|
|
1419
|
+
},
|
|
1420
|
+
{
|
|
1421
|
+
name: "get",
|
|
1422
|
+
category: "object",
|
|
1423
|
+
compatibility: ["browser", "nodejs"],
|
|
1424
|
+
fn: getHelper
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
name: "getObject",
|
|
1428
|
+
category: "object",
|
|
1429
|
+
compatibility: ["browser", "nodejs"],
|
|
1430
|
+
fn: getObjectHelper
|
|
1431
|
+
},
|
|
1432
|
+
{
|
|
1433
|
+
name: "hasOwn",
|
|
1434
|
+
category: "object",
|
|
1435
|
+
compatibility: ["browser", "nodejs"],
|
|
1436
|
+
fn: hasOwn
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
name: "isObject",
|
|
1440
|
+
category: "object",
|
|
1441
|
+
compatibility: ["browser", "nodejs"],
|
|
1442
|
+
fn: isObject
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
name: "JSONparse",
|
|
1446
|
+
category: "object",
|
|
1447
|
+
compatibility: ["browser", "nodejs"],
|
|
1448
|
+
fn: JSONparse
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
name: "JSONstringify",
|
|
1452
|
+
category: "object",
|
|
1453
|
+
compatibility: ["browser", "nodejs"],
|
|
1454
|
+
fn: JSONstringify
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
name: "merge",
|
|
1458
|
+
category: "object",
|
|
1459
|
+
compatibility: ["browser", "nodejs"],
|
|
1460
|
+
fn: merge
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
name: "parseJSON",
|
|
1464
|
+
category: "object",
|
|
1465
|
+
compatibility: ["browser", "nodejs"],
|
|
1466
|
+
fn: parseJSON
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
name: "pick",
|
|
1470
|
+
category: "object",
|
|
1471
|
+
compatibility: ["browser", "nodejs"],
|
|
1472
|
+
fn: pick
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
name: "stringify",
|
|
1476
|
+
category: "object",
|
|
1477
|
+
compatibility: ["browser", "nodejs"],
|
|
1478
|
+
fn: stringify
|
|
874
1479
|
}
|
|
875
|
-
|
|
1480
|
+
];
|
|
876
1481
|
|
|
877
|
-
// helpers/
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (number == null) return "0 B";
|
|
887
|
-
if (!utils.isNumber(number)) {
|
|
888
|
-
number = number.length;
|
|
889
|
-
if (!number) return "0 B";
|
|
890
|
-
}
|
|
891
|
-
if (!utils.isNumber(precision)) {
|
|
892
|
-
precision = 2;
|
|
893
|
-
}
|
|
894
|
-
var abbr = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
895
|
-
precision = Math.pow(10, precision);
|
|
896
|
-
number = Number(number);
|
|
897
|
-
var len = abbr.length - 1;
|
|
898
|
-
while (len-- >= 0) {
|
|
899
|
-
var size = Math.pow(10, len * 3);
|
|
900
|
-
if (size <= number + 1) {
|
|
901
|
-
number = Math.round(number * precision / size) / precision;
|
|
902
|
-
number += " " + abbr[len];
|
|
903
|
-
break;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
return number;
|
|
907
|
-
};
|
|
908
|
-
helpers3.addCommas = function(num) {
|
|
909
|
-
return num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
|
910
|
-
};
|
|
911
|
-
helpers3.phoneNumber = function(num) {
|
|
912
|
-
num = num.toString();
|
|
913
|
-
return "(" + num.substr(0, 3) + ") " + num.substr(3, 3) + "-" + num.substr(6, 4);
|
|
914
|
-
};
|
|
915
|
-
helpers3.toAbbr = function(number, precision) {
|
|
916
|
-
if (!utils.isNumber(number)) {
|
|
917
|
-
number = 0;
|
|
918
|
-
}
|
|
919
|
-
if (util.isUndefined(precision)) {
|
|
920
|
-
precision = 2;
|
|
921
|
-
}
|
|
922
|
-
number = Number(number);
|
|
923
|
-
precision = Math.pow(10, precision);
|
|
924
|
-
var abbr = ["k", "m", "b", "t", "q"];
|
|
925
|
-
var len = abbr.length - 1;
|
|
926
|
-
while (len >= 0) {
|
|
927
|
-
var size = Math.pow(10, (len + 1) * 3);
|
|
928
|
-
if (size <= number + 1) {
|
|
929
|
-
number = Math.round(number * precision / size) / precision;
|
|
930
|
-
number += abbr[len];
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
len--;
|
|
934
|
-
}
|
|
935
|
-
return number;
|
|
936
|
-
};
|
|
937
|
-
helpers3.toExponential = function(number, digits) {
|
|
938
|
-
if (!utils.isNumber(number)) {
|
|
939
|
-
number = 0;
|
|
940
|
-
}
|
|
941
|
-
if (util.isUndefined(digits)) {
|
|
942
|
-
digits = 0;
|
|
943
|
-
}
|
|
944
|
-
return Number(number).toExponential(digits);
|
|
945
|
-
};
|
|
946
|
-
helpers3.toFixed = function(number, digits) {
|
|
947
|
-
if (!utils.isNumber(number)) {
|
|
948
|
-
number = 0;
|
|
949
|
-
}
|
|
950
|
-
if (!isNumber(digits)) {
|
|
951
|
-
digits = 0;
|
|
952
|
-
}
|
|
953
|
-
return Number(number).toFixed(digits);
|
|
954
|
-
};
|
|
955
|
-
helpers3.toFloat = function(number) {
|
|
956
|
-
return parseFloat(number);
|
|
957
|
-
};
|
|
958
|
-
helpers3.toInt = function(number) {
|
|
959
|
-
return parseInt(number, 10);
|
|
960
|
-
};
|
|
961
|
-
helpers3.toPrecision = function(number, precision) {
|
|
962
|
-
if (!utils.isNumber(number)) {
|
|
963
|
-
number = 0;
|
|
964
|
-
}
|
|
965
|
-
if (!isNumber(precision)) {
|
|
966
|
-
precision = 1;
|
|
967
|
-
}
|
|
968
|
-
return Number(number).toPrecision(precision);
|
|
969
|
-
};
|
|
1482
|
+
// src/helpers/path.ts
|
|
1483
|
+
import path5 from "path";
|
|
1484
|
+
var expectedType = (variableName, expectedType2, variableValue) => {
|
|
1485
|
+
const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
|
|
1486
|
+
return `Expected ${variableName} to be of type ${expectedType2}, but got ${actualType}`;
|
|
1487
|
+
};
|
|
1488
|
+
var assertString = (name, value) => {
|
|
1489
|
+
if (typeof value !== "string") {
|
|
1490
|
+
throw new TypeError(expectedType(name, "string", value));
|
|
970
1491
|
}
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const isMatch = utils.mm.matcher(filter);
|
|
1005
|
-
const result = [];
|
|
1006
|
-
for (let i = 0; i < files.length; i++) {
|
|
1007
|
-
if (isMatch(files[i])) {
|
|
1008
|
-
result.push(files[i]);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return result;
|
|
1012
|
-
}
|
|
1013
|
-
if (["isFile", "isDirectory"].indexOf(filter) !== -1) {
|
|
1014
|
-
return files.filter(function(fp) {
|
|
1015
|
-
var stat = fs.statSync(fp);
|
|
1016
|
-
return stat[filter]();
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
return files;
|
|
1020
|
-
};
|
|
1492
|
+
return value;
|
|
1493
|
+
};
|
|
1494
|
+
var absolute = function(filepath, options) {
|
|
1495
|
+
const fp = assertString("filepath", filepath);
|
|
1496
|
+
const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1497
|
+
return path5.resolve(cwd, fp);
|
|
1498
|
+
};
|
|
1499
|
+
var dirname = (filepath) => {
|
|
1500
|
+
const fp = assertString("filepath", filepath);
|
|
1501
|
+
return path5.dirname(fp);
|
|
1502
|
+
};
|
|
1503
|
+
var relative = (a, b) => {
|
|
1504
|
+
const from = assertString("first path", a);
|
|
1505
|
+
const to = assertString("second path", b);
|
|
1506
|
+
return path5.relative(path5.dirname(from), to);
|
|
1507
|
+
};
|
|
1508
|
+
var basename = (filepath) => {
|
|
1509
|
+
const fp = assertString("filepath", filepath);
|
|
1510
|
+
return path5.basename(fp);
|
|
1511
|
+
};
|
|
1512
|
+
var stem = (filepath) => {
|
|
1513
|
+
const fp = assertString("filepath", filepath);
|
|
1514
|
+
return path5.basename(fp, path5.extname(fp));
|
|
1515
|
+
};
|
|
1516
|
+
var extname = (filepath) => {
|
|
1517
|
+
const fp = assertString("filepath", filepath);
|
|
1518
|
+
return path5.extname(fp);
|
|
1519
|
+
};
|
|
1520
|
+
var resolveFn = function(filepath, ...paths) {
|
|
1521
|
+
let options;
|
|
1522
|
+
const last2 = paths[paths.length - 1];
|
|
1523
|
+
if (typeof last2 === "object" && last2 && "data" in last2) {
|
|
1524
|
+
options = paths.pop();
|
|
1021
1525
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1526
|
+
const cwd = options?.data?.root?.cwd ?? this?.cwd ?? process.cwd();
|
|
1527
|
+
const all2 = [
|
|
1528
|
+
cwd,
|
|
1529
|
+
assertString("filepath", filepath),
|
|
1530
|
+
...paths.map((p, i) => assertString(`path${i}`, p))
|
|
1531
|
+
];
|
|
1532
|
+
return path5.resolve(...all2);
|
|
1533
|
+
};
|
|
1534
|
+
var segments = (filepath, a, b) => {
|
|
1535
|
+
const fp = assertString("filepath", filepath);
|
|
1536
|
+
const start = Number(a);
|
|
1537
|
+
const end = Number(b);
|
|
1538
|
+
const segmentsArr = fp.split(/[\\/]+/);
|
|
1539
|
+
return segmentsArr.slice(start, end).join("/");
|
|
1540
|
+
};
|
|
1541
|
+
var helpers17 = [
|
|
1542
|
+
{
|
|
1543
|
+
name: "absolute",
|
|
1544
|
+
category: "path",
|
|
1545
|
+
compatibility: ["nodejs"],
|
|
1546
|
+
fn: absolute
|
|
1547
|
+
},
|
|
1548
|
+
{
|
|
1549
|
+
name: "dirname",
|
|
1550
|
+
category: "path",
|
|
1551
|
+
compatibility: ["nodejs"],
|
|
1552
|
+
fn: dirname
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
name: "relative",
|
|
1556
|
+
category: "path",
|
|
1557
|
+
compatibility: ["nodejs"],
|
|
1558
|
+
fn: relative
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
name: "basename",
|
|
1562
|
+
category: "path",
|
|
1563
|
+
compatibility: ["nodejs"],
|
|
1564
|
+
fn: basename
|
|
1565
|
+
},
|
|
1566
|
+
{
|
|
1567
|
+
name: "stem",
|
|
1568
|
+
category: "path",
|
|
1569
|
+
compatibility: ["nodejs"],
|
|
1570
|
+
fn: stem
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
name: "extname",
|
|
1574
|
+
category: "path",
|
|
1575
|
+
compatibility: ["nodejs"],
|
|
1576
|
+
fn: extname
|
|
1577
|
+
},
|
|
1578
|
+
{
|
|
1579
|
+
name: "resolve",
|
|
1580
|
+
category: "path",
|
|
1581
|
+
compatibility: ["nodejs"],
|
|
1582
|
+
fn: resolveFn
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
name: "segments",
|
|
1586
|
+
category: "path",
|
|
1587
|
+
compatibility: ["nodejs"],
|
|
1588
|
+
fn: segments
|
|
1060
1589
|
}
|
|
1061
|
-
|
|
1590
|
+
];
|
|
1062
1591
|
|
|
1063
|
-
// helpers/
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
var helpers3 = module2.exports;
|
|
1073
|
-
helpers3.attr = function(options) {
|
|
1074
|
-
var val = parseAttr(options && options.hash || {});
|
|
1075
|
-
return val.trim() ? " " + val : "";
|
|
1076
|
-
};
|
|
1077
|
-
helpers3.css = function(list, options) {
|
|
1078
|
-
if (arguments.length < 2) {
|
|
1079
|
-
options = list;
|
|
1080
|
-
list = [];
|
|
1081
|
-
}
|
|
1082
|
-
var styles = util.arrayify(list);
|
|
1083
|
-
var assets = "";
|
|
1084
|
-
if (this && this.options) {
|
|
1085
|
-
assets = this.options.assets || "";
|
|
1086
|
-
}
|
|
1087
|
-
if (options.hash.href) {
|
|
1088
|
-
styles = util.arrayify(options.hash.href);
|
|
1089
|
-
}
|
|
1090
|
-
return styles.map(function(item) {
|
|
1091
|
-
var ext = path.extname(item);
|
|
1092
|
-
var fp = item;
|
|
1093
|
-
if (!/(^\/\/)|(:\/\/)/.test(item)) {
|
|
1094
|
-
fp = path.posix.join(assets, item);
|
|
1095
|
-
}
|
|
1096
|
-
if (ext === ".less") {
|
|
1097
|
-
return '<link type="text/css" rel="stylesheet/less" href="' + fp + '">';
|
|
1098
|
-
}
|
|
1099
|
-
return '<link type="text/css" rel="stylesheet" href="' + fp + '">';
|
|
1100
|
-
}).join("\n");
|
|
1101
|
-
};
|
|
1102
|
-
helpers3.js = function(context) {
|
|
1103
|
-
if (utils.typeOf(context) === "object") {
|
|
1104
|
-
var attr = parseAttr(context.hash);
|
|
1105
|
-
return "<script" + (attr ? " " + attr : "") + "></script>";
|
|
1106
|
-
}
|
|
1107
|
-
if (utils.typeOf(context) === "string") {
|
|
1108
|
-
return '<script src="' + context + '"></script>';
|
|
1109
|
-
}
|
|
1110
|
-
context = util.arrayify(context);
|
|
1111
|
-
return context.map(function(fp) {
|
|
1112
|
-
return path.extname(fp) === ".coffee" ? utils.tag("script", { type: "text/coffeescript", src: fp }) : utils.tag("script", { src: fp });
|
|
1113
|
-
}).join("\n");
|
|
1114
|
-
};
|
|
1115
|
-
helpers3.sanitize = function(str) {
|
|
1116
|
-
return html.sanitize(str);
|
|
1117
|
-
};
|
|
1118
|
-
helpers3.ul = function(context, options) {
|
|
1119
|
-
return "<ul " + parseAttr(options.hash) + ">" + context.map(function(item) {
|
|
1120
|
-
if (typeof item !== "string") {
|
|
1121
|
-
item = options.fn(item);
|
|
1122
|
-
}
|
|
1123
|
-
return "<li>" + item + "</li>";
|
|
1124
|
-
}).join("\n") + "</ul>";
|
|
1125
|
-
};
|
|
1126
|
-
helpers3.ol = function(context, options) {
|
|
1127
|
-
return "<ol " + parseAttr(options.hash) + ">" + context.map(function(item) {
|
|
1128
|
-
if (typeof item !== "string") {
|
|
1129
|
-
item = options.fn(item);
|
|
1130
|
-
}
|
|
1131
|
-
return "<li>" + item + "</li>";
|
|
1132
|
-
}).join("\n") + "</ol>";
|
|
1133
|
-
};
|
|
1134
|
-
helpers3.thumbnailImage = function(context) {
|
|
1135
|
-
var figure = "";
|
|
1136
|
-
var image = "";
|
|
1137
|
-
var link = context.full || false;
|
|
1138
|
-
var imageAttributes = {
|
|
1139
|
-
alt: context.alt,
|
|
1140
|
-
src: context.thumbnail,
|
|
1141
|
-
width: context.size.width,
|
|
1142
|
-
height: context.size.height
|
|
1143
|
-
};
|
|
1144
|
-
var figureAttributes = { id: "image-" + context.id };
|
|
1145
|
-
var linkAttributes = { href: link, rel: "thumbnail" };
|
|
1146
|
-
if (context.classes) {
|
|
1147
|
-
if (context.classes.image) {
|
|
1148
|
-
imageAttributes.class = context.classes.image.join(" ");
|
|
1149
|
-
}
|
|
1150
|
-
if (context.classes.figure) {
|
|
1151
|
-
figureAttributes.class = context.classes.figure.join(" ");
|
|
1152
|
-
}
|
|
1153
|
-
if (context.classes.link) {
|
|
1154
|
-
linkAttributes.class = context.classes.link.join(" ");
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
figure += "<figure " + parseAttr(figureAttributes) + ">\n";
|
|
1158
|
-
image += "<img " + parseAttr(imageAttributes) + ">\n";
|
|
1159
|
-
if (link) {
|
|
1160
|
-
figure += "<a " + parseAttr(linkAttributes) + ">\n" + image + "</a>\n";
|
|
1161
|
-
} else {
|
|
1162
|
-
figure += image;
|
|
1163
|
-
}
|
|
1164
|
-
if (context.caption) {
|
|
1165
|
-
figure += "<figcaption>" + context.caption + "</figcaption>\n";
|
|
1166
|
-
}
|
|
1167
|
-
figure += "</figure>";
|
|
1168
|
-
return figure;
|
|
1169
|
-
};
|
|
1592
|
+
// src/helpers/regex.ts
|
|
1593
|
+
import util2 from "handlebars-utils";
|
|
1594
|
+
var toRegex = (str, locals, options) => {
|
|
1595
|
+
const opts = util2.options({}, locals, options);
|
|
1596
|
+
return new RegExp(str, opts.flags);
|
|
1597
|
+
};
|
|
1598
|
+
var test = (str, regex) => {
|
|
1599
|
+
if (typeof str !== "string") {
|
|
1600
|
+
return false;
|
|
1170
1601
|
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
// helpers/lib/i18n.js
|
|
1174
|
-
var require_i18n = __commonJS({
|
|
1175
|
-
"helpers/lib/i18n.js"(exports2, module2) {
|
|
1176
|
-
"use strict";
|
|
1177
|
-
var util = require("handlebars-utils");
|
|
1178
|
-
var utils = require_utils2();
|
|
1179
|
-
var helpers3 = module2.exports;
|
|
1180
|
-
helpers3.i18n = function(prop, locals, options) {
|
|
1181
|
-
if (util.isOptions(locals)) {
|
|
1182
|
-
options = locals;
|
|
1183
|
-
locals = {};
|
|
1184
|
-
}
|
|
1185
|
-
if (!util.isString(prop)) {
|
|
1186
|
-
throw new Error('{{i18n}} helper expected "key" to be a string');
|
|
1187
|
-
}
|
|
1188
|
-
var opts = util.options(this, locals, options);
|
|
1189
|
-
var context = Object.assign({}, this, opts);
|
|
1190
|
-
var lang = context.language || context.lang;
|
|
1191
|
-
if (!util.isString(lang)) {
|
|
1192
|
-
throw new TypeError('{{i18n}} helper expected "language" to be a string');
|
|
1193
|
-
}
|
|
1194
|
-
var cache = context[lang];
|
|
1195
|
-
if (typeof cache === "undefined") {
|
|
1196
|
-
throw new Error('{{i18n}} helper cannot find language "' + lang + '"');
|
|
1197
|
-
}
|
|
1198
|
-
var result = utils.get(cache, prop);
|
|
1199
|
-
if (typeof result === "undefined") {
|
|
1200
|
-
throw new Error('{{i18n}} helper cannot find property "' + prop + '" for language "' + lang + '"');
|
|
1201
|
-
}
|
|
1202
|
-
return result;
|
|
1203
|
-
};
|
|
1602
|
+
if (!(regex instanceof RegExp)) {
|
|
1603
|
+
throw new TypeError("expected a regular expression");
|
|
1204
1604
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
helpers3.ordinalize = function(val) {
|
|
1222
|
-
var num = Math.abs(Math.round(val));
|
|
1223
|
-
var str = String(val);
|
|
1224
|
-
var res = num % 100;
|
|
1225
|
-
if (util.indexOf([11, 12, 13], res) >= 0) {
|
|
1226
|
-
return str + "th";
|
|
1227
|
-
}
|
|
1228
|
-
switch (num % 10) {
|
|
1229
|
-
case 1:
|
|
1230
|
-
return str + "st";
|
|
1231
|
-
case 2:
|
|
1232
|
-
return str + "nd";
|
|
1233
|
-
case 3:
|
|
1234
|
-
return str + "rd";
|
|
1235
|
-
default: {
|
|
1236
|
-
return str + "th";
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
};
|
|
1605
|
+
return regex.test(str);
|
|
1606
|
+
};
|
|
1607
|
+
var helpers18 = [
|
|
1608
|
+
{
|
|
1609
|
+
name: "toRegex",
|
|
1610
|
+
category: "regex",
|
|
1611
|
+
compatibility: ["browser", "nodejs"],
|
|
1612
|
+
fn: toRegex
|
|
1613
|
+
},
|
|
1614
|
+
{
|
|
1615
|
+
name: "test",
|
|
1616
|
+
category: "regex",
|
|
1617
|
+
compatibility: ["browser", "nodejs"],
|
|
1618
|
+
fn: test
|
|
1240
1619
|
}
|
|
1241
|
-
|
|
1620
|
+
];
|
|
1242
1621
|
|
|
1243
|
-
// helpers/
|
|
1244
|
-
var
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1622
|
+
// src/helpers/string.ts
|
|
1623
|
+
var chop = (str) => str.trim().replace(/^[-_.\W\s]+|[-_.\W\s]+$/g, "");
|
|
1624
|
+
var changecase = (str, fn) => {
|
|
1625
|
+
if (str.length === 1) return str.toLowerCase();
|
|
1626
|
+
const res = chop(str).toLowerCase();
|
|
1627
|
+
return res.replace(/[-_.\W\s]+(\w|$)/g, (_, ch) => fn(ch));
|
|
1628
|
+
};
|
|
1629
|
+
var append = (str, suffix) => {
|
|
1630
|
+
if (typeof str === "string" && typeof suffix === "string") {
|
|
1631
|
+
return str + suffix;
|
|
1248
1632
|
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
var
|
|
1253
|
-
"
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
if (exists(filepath)) {
|
|
1279
|
-
this.app.create("mdfiles");
|
|
1280
|
-
str = fs.readFileSync(filepath, "utf8");
|
|
1281
|
-
view = this.app.mdfile(filepath, { path: filepath, content: str });
|
|
1282
|
-
} else {
|
|
1283
|
-
view = this.app.find(name);
|
|
1284
|
-
}
|
|
1285
|
-
if (typeof view === "undefined") {
|
|
1286
|
-
cb(null, "");
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
view.content = ent.decode(md.render(view.content));
|
|
1290
|
-
this.app.render(view, this.context, function(err, res) {
|
|
1291
|
-
if (err) return cb(err);
|
|
1292
|
-
cb(null, res.content);
|
|
1293
|
-
});
|
|
1294
|
-
};
|
|
1295
|
-
helper.sync = function(name, options) {
|
|
1296
|
-
var ctx = this || {};
|
|
1297
|
-
var app = ctx.app || {};
|
|
1298
|
-
var opts = extend({ cwd: process.cwd() }, ctx.options, options);
|
|
1299
|
-
opts = extend({}, opts, opts.hash);
|
|
1300
|
-
var md = markdown(opts);
|
|
1301
|
-
var filepath = path.resolve(opts.cwd, name);
|
|
1302
|
-
var view;
|
|
1303
|
-
var html = "";
|
|
1304
|
-
var str = "";
|
|
1305
|
-
if (exists(filepath)) {
|
|
1306
|
-
str = fs.readFileSync(filepath, "utf8");
|
|
1307
|
-
html = ent.decode(md.render(str));
|
|
1308
|
-
} else if (app.views) {
|
|
1309
|
-
view = app.find(name);
|
|
1310
|
-
if (view) {
|
|
1311
|
-
html = view.content = ent.decode(md.render(view.content));
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
if (view && typeof view.compile === "function") {
|
|
1315
|
-
view.compile(opts);
|
|
1316
|
-
var data = ctx.cache ? ctx.cache.data : {};
|
|
1317
|
-
ctx = extend({}, data, view.data);
|
|
1318
|
-
return view.fn(ctx);
|
|
1319
|
-
}
|
|
1320
|
-
if (typeof this.compile === "function") {
|
|
1321
|
-
var fn = this.compile(html);
|
|
1322
|
-
return fn(this);
|
|
1323
|
-
}
|
|
1324
|
-
return html;
|
|
1325
|
-
};
|
|
1326
|
-
function markdown(options) {
|
|
1327
|
-
let optsConfig = options || {};
|
|
1328
|
-
optsConfig.breaks = true;
|
|
1329
|
-
optsConfig.html = true;
|
|
1330
|
-
optsConfig.langPrefix = "lang-";
|
|
1331
|
-
optsConfig.typographer = false;
|
|
1332
|
-
optsConfig.xhtmlOut = false;
|
|
1333
|
-
const md = new Remarkable(optsConfig);
|
|
1334
|
-
return md;
|
|
1633
|
+
return str;
|
|
1634
|
+
};
|
|
1635
|
+
var camelcase = (str) => typeof str === "string" ? changecase(str, (ch) => ch.toUpperCase()) : "";
|
|
1636
|
+
var capitalize = (str) => {
|
|
1637
|
+
if (typeof str !== "string" || str.length === 0) return "";
|
|
1638
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1639
|
+
};
|
|
1640
|
+
var capitalizeAll = (str) => {
|
|
1641
|
+
if (typeof str !== "string") return "";
|
|
1642
|
+
return str.replace(/\w\S*/g, (word) => capitalize(word));
|
|
1643
|
+
};
|
|
1644
|
+
var center = (str, spaces) => {
|
|
1645
|
+
if (typeof str !== "string") return "";
|
|
1646
|
+
let space = "";
|
|
1647
|
+
for (let i = 0; i < spaces; i++) {
|
|
1648
|
+
space += " ";
|
|
1649
|
+
}
|
|
1650
|
+
return space + str + space;
|
|
1651
|
+
};
|
|
1652
|
+
var chopStr = (str) => typeof str === "string" ? chop(str) : "";
|
|
1653
|
+
var dashcase = (str) => typeof str === "string" ? changecase(str, (ch) => `-${ch}`) : "";
|
|
1654
|
+
var dotcase = (str) => typeof str === "string" ? changecase(str, (ch) => `.${ch}`) : "";
|
|
1655
|
+
var truncate = (str, limit, suffix) => {
|
|
1656
|
+
if (typeof str === "string") {
|
|
1657
|
+
if (typeof suffix !== "string") {
|
|
1658
|
+
suffix = "";
|
|
1659
|
+
}
|
|
1660
|
+
if (str.length > limit) {
|
|
1661
|
+
return str.slice(0, limit - suffix.length) + suffix;
|
|
1335
1662
|
}
|
|
1663
|
+
return str;
|
|
1336
1664
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
var { Remarkable } = require("remarkable");
|
|
1346
|
-
var helpers3 = module2.exports;
|
|
1347
|
-
var markdown;
|
|
1348
|
-
Object.defineProperty(helpers3, "markdown", {
|
|
1349
|
-
configurable: true,
|
|
1350
|
-
enumerable: true,
|
|
1351
|
-
set: function(val) {
|
|
1352
|
-
markdown = val;
|
|
1353
|
-
},
|
|
1354
|
-
get: function() {
|
|
1355
|
-
return markdown || (markdown = this.helpersForMarkdown());
|
|
1356
|
-
}
|
|
1357
|
-
});
|
|
1358
|
-
helpers3.md = require_md();
|
|
1359
|
-
helpers3.helpersForMarkdown = function(config) {
|
|
1360
|
-
const defaults = { html: true, breaks: true, highlight: helpers3.highlightFormMarkdown };
|
|
1361
|
-
if (typeof config === "string" || utils.isOptions(config)) {
|
|
1362
|
-
return markdown2.apply(defaults, arguments);
|
|
1363
|
-
}
|
|
1364
|
-
function markdown2(str, locals, options) {
|
|
1365
|
-
if (typeof str !== "string") {
|
|
1366
|
-
options = locals;
|
|
1367
|
-
locals = str;
|
|
1368
|
-
str = true;
|
|
1369
|
-
}
|
|
1370
|
-
if (utils.isOptions(locals)) {
|
|
1371
|
-
options = locals;
|
|
1372
|
-
locals = {};
|
|
1373
|
-
}
|
|
1374
|
-
const ctx = utils.context(this, locals, options);
|
|
1375
|
-
let opts = utils.options(this, locals, options);
|
|
1376
|
-
opts = Object.assign({}, defaults, config, opts);
|
|
1377
|
-
if (opts.hasOwnProperty("lang")) {
|
|
1378
|
-
opts.langPrefix = opts.lang;
|
|
1379
|
-
}
|
|
1380
|
-
const md = new Remarkable(opts);
|
|
1381
|
-
const val = utils.value(str, ctx, options);
|
|
1382
|
-
return md.render(val);
|
|
1383
|
-
}
|
|
1384
|
-
return markdown2;
|
|
1385
|
-
};
|
|
1386
|
-
helpers3.highlightFormMarkdown = function(code, lang) {
|
|
1387
|
-
if (lang) {
|
|
1388
|
-
return hljs.highlight(code, { language: lang }).value;
|
|
1389
|
-
}
|
|
1390
|
-
return hljs.highlightAuto(code).value;
|
|
1391
|
-
};
|
|
1665
|
+
return "";
|
|
1666
|
+
};
|
|
1667
|
+
var ellipsis = (str, limit) => {
|
|
1668
|
+
if (typeof str === "string") {
|
|
1669
|
+
if (str.length <= limit) {
|
|
1670
|
+
return str;
|
|
1671
|
+
}
|
|
1672
|
+
return `${truncate(str, limit)}\u2026`;
|
|
1392
1673
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
var
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
var utils = require_utils2();
|
|
1401
|
-
var helpers3 = module2.exports;
|
|
1402
|
-
helpers3.match = function(files, patterns, locals, options) {
|
|
1403
|
-
var opts = util.options(this, locals, options);
|
|
1404
|
-
if (typeof patterns === "string") {
|
|
1405
|
-
patterns = patterns.split(/, */);
|
|
1406
|
-
}
|
|
1407
|
-
return utils.mm(files, patterns, opts);
|
|
1408
|
-
};
|
|
1409
|
-
helpers3.isMatch = function(files, patterns, locals, options) {
|
|
1410
|
-
var opts = util.options(this, locals, options);
|
|
1411
|
-
return utils.mm.isMatch(files, patterns, opts);
|
|
1412
|
-
};
|
|
1413
|
-
helpers3.mm = function() {
|
|
1414
|
-
console.log("the {{mm}} helper is depcrecated and will be removed");
|
|
1415
|
-
console.log("in handlebars-helpers v1.0.0, please use the {{match}}");
|
|
1416
|
-
console.log("helper instead.");
|
|
1417
|
-
return helpers3.match.apply(this, arguments);
|
|
1418
|
-
};
|
|
1674
|
+
return "";
|
|
1675
|
+
};
|
|
1676
|
+
var hyphenate = (str) => typeof str === "string" ? str.split(" ").join("-") : "";
|
|
1677
|
+
var isString = (value) => typeof value === "string";
|
|
1678
|
+
var lowercase = (str) => {
|
|
1679
|
+
if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
|
|
1680
|
+
return String(str.fn()).toLowerCase();
|
|
1419
1681
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
var
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
}
|
|
1433
|
-
return Math.abs(num);
|
|
1434
|
-
};
|
|
1435
|
-
helpers3.add = function(a, b) {
|
|
1436
|
-
if (isNumber(a) && isNumber(b)) {
|
|
1437
|
-
return Number(a) + Number(b);
|
|
1438
|
-
}
|
|
1439
|
-
return "";
|
|
1440
|
-
};
|
|
1441
|
-
helpers3.avg = function() {
|
|
1442
|
-
var args = [].concat.apply([], arguments);
|
|
1443
|
-
args.pop();
|
|
1444
|
-
return helpers3.sum(args) / args.length;
|
|
1445
|
-
};
|
|
1446
|
-
helpers3.ceil = function(num) {
|
|
1447
|
-
if (!isNumber(num)) {
|
|
1448
|
-
throw new TypeError("expected a number");
|
|
1449
|
-
}
|
|
1450
|
-
return Math.ceil(num);
|
|
1451
|
-
};
|
|
1452
|
-
helpers3.divide = function(a, b) {
|
|
1453
|
-
if (!isNumber(a)) {
|
|
1454
|
-
throw new TypeError("expected the first argument to be a number");
|
|
1455
|
-
}
|
|
1456
|
-
if (!isNumber(b)) {
|
|
1457
|
-
throw new TypeError("expected the second argument to be a number");
|
|
1458
|
-
}
|
|
1459
|
-
return Number(a) / Number(b);
|
|
1460
|
-
};
|
|
1461
|
-
helpers3.floor = function(num) {
|
|
1462
|
-
if (!isNumber(num)) {
|
|
1463
|
-
throw new TypeError("expected a number");
|
|
1464
|
-
}
|
|
1465
|
-
return Math.floor(num);
|
|
1466
|
-
};
|
|
1467
|
-
helpers3.minus = function(a, b) {
|
|
1468
|
-
if (!isNumber(a)) {
|
|
1469
|
-
throw new TypeError("expected the first argument to be a number");
|
|
1470
|
-
}
|
|
1471
|
-
if (!isNumber(b)) {
|
|
1472
|
-
throw new TypeError("expected the second argument to be a number");
|
|
1473
|
-
}
|
|
1474
|
-
return Number(a) - Number(b);
|
|
1475
|
-
};
|
|
1476
|
-
helpers3.modulo = function(a, b) {
|
|
1477
|
-
if (!isNumber(a)) {
|
|
1478
|
-
throw new TypeError("expected the first argument to be a number");
|
|
1479
|
-
}
|
|
1480
|
-
if (!isNumber(b)) {
|
|
1481
|
-
throw new TypeError("expected the second argument to be a number");
|
|
1482
|
-
}
|
|
1483
|
-
return Number(a) % Number(b);
|
|
1484
|
-
};
|
|
1485
|
-
helpers3.multiply = function(a, b) {
|
|
1486
|
-
if (!isNumber(a)) {
|
|
1487
|
-
throw new TypeError("expected the first argument to be a number");
|
|
1488
|
-
}
|
|
1489
|
-
if (!isNumber(b)) {
|
|
1490
|
-
throw new TypeError("expected the second argument to be a number");
|
|
1491
|
-
}
|
|
1492
|
-
return Number(a) * Number(b);
|
|
1493
|
-
};
|
|
1494
|
-
helpers3.plus = function(a, b) {
|
|
1495
|
-
if (!isNumber(a)) {
|
|
1496
|
-
throw new TypeError("expected the first argument to be a number");
|
|
1497
|
-
}
|
|
1498
|
-
if (!isNumber(b)) {
|
|
1499
|
-
throw new TypeError("expected the second argument to be a number");
|
|
1500
|
-
}
|
|
1501
|
-
return Number(a) + Number(b);
|
|
1502
|
-
};
|
|
1503
|
-
helpers3.random = function(min, max) {
|
|
1504
|
-
if (!isNumber(min)) {
|
|
1505
|
-
throw new TypeError("expected minimum to be a number");
|
|
1506
|
-
}
|
|
1507
|
-
if (!isNumber(max)) {
|
|
1508
|
-
throw new TypeError("expected maximum to be a number");
|
|
1509
|
-
}
|
|
1510
|
-
return utils.random(min, max);
|
|
1511
|
-
};
|
|
1512
|
-
helpers3.remainder = function(a, b) {
|
|
1513
|
-
return a % b;
|
|
1514
|
-
};
|
|
1515
|
-
helpers3.round = function(num) {
|
|
1516
|
-
if (!isNumber(num)) {
|
|
1517
|
-
throw new TypeError("expected a number");
|
|
1518
|
-
}
|
|
1519
|
-
return Math.round(num);
|
|
1520
|
-
};
|
|
1521
|
-
helpers3.subtract = function(a, b) {
|
|
1522
|
-
if (!isNumber(a)) {
|
|
1523
|
-
throw new TypeError("expected the first argument to be a number");
|
|
1524
|
-
}
|
|
1525
|
-
if (!isNumber(b)) {
|
|
1526
|
-
throw new TypeError("expected the second argument to be a number");
|
|
1527
|
-
}
|
|
1528
|
-
return Number(a) - Number(b);
|
|
1529
|
-
};
|
|
1530
|
-
helpers3.sum = function() {
|
|
1531
|
-
var args = [].concat.apply([], arguments);
|
|
1532
|
-
var len = args.length;
|
|
1533
|
-
var sum = 0;
|
|
1534
|
-
while (len--) {
|
|
1535
|
-
if (utils.isNumber(args[len])) {
|
|
1536
|
-
sum += Number(args[len]);
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
return sum;
|
|
1540
|
-
};
|
|
1541
|
-
helpers3.times = function() {
|
|
1542
|
-
return helpers3.multiply.apply(this, arguments);
|
|
1543
|
-
};
|
|
1682
|
+
if (typeof str !== "string") return "";
|
|
1683
|
+
return str.toLowerCase();
|
|
1684
|
+
};
|
|
1685
|
+
var downcase = (...args) => lowercase(...args);
|
|
1686
|
+
var occurrences = (str, substring) => {
|
|
1687
|
+
if (typeof str !== "string") return "";
|
|
1688
|
+
const len = substring.length;
|
|
1689
|
+
let pos = str.indexOf(substring, 0);
|
|
1690
|
+
let n = 0;
|
|
1691
|
+
while (pos > -1) {
|
|
1692
|
+
n++;
|
|
1693
|
+
pos = str.indexOf(substring, pos + len);
|
|
1544
1694
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1695
|
+
return n;
|
|
1696
|
+
};
|
|
1697
|
+
var pascalcase = (str) => {
|
|
1698
|
+
if (typeof str !== "string") return "";
|
|
1699
|
+
const res = changecase(str, (ch) => ch.toUpperCase());
|
|
1700
|
+
return res.charAt(0).toUpperCase() + res.slice(1);
|
|
1701
|
+
};
|
|
1702
|
+
var pathcase = (str) => typeof str === "string" ? changecase(str, (ch) => `/${ch}`) : "";
|
|
1703
|
+
var plusify = (str, ch) => {
|
|
1704
|
+
if (typeof str !== "string") return "";
|
|
1705
|
+
if (typeof ch !== "string") ch = " ";
|
|
1706
|
+
return str.split(ch).join("+");
|
|
1707
|
+
};
|
|
1708
|
+
var prepend = (str, prefix) => {
|
|
1709
|
+
return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
|
|
1710
|
+
};
|
|
1711
|
+
var remove = (str, ch) => {
|
|
1712
|
+
if (typeof str !== "string") return "";
|
|
1713
|
+
if (typeof ch !== "string") return str;
|
|
1714
|
+
return str.split(ch).join("");
|
|
1715
|
+
};
|
|
1716
|
+
var removeFirst = (str, ch) => {
|
|
1717
|
+
if (typeof str !== "string") return "";
|
|
1718
|
+
if (typeof ch !== "string") return str;
|
|
1719
|
+
return str.replace(ch, "");
|
|
1720
|
+
};
|
|
1721
|
+
var replace = (str, a, b) => {
|
|
1722
|
+
if (typeof str !== "string") return "";
|
|
1723
|
+
if (typeof a !== "string") return str;
|
|
1724
|
+
if (typeof b !== "string") b = "";
|
|
1725
|
+
return str.split(a).join(b);
|
|
1726
|
+
};
|
|
1727
|
+
var replaceFirst = (str, a, b) => {
|
|
1728
|
+
if (typeof str !== "string") return "";
|
|
1729
|
+
if (typeof a !== "string") return str;
|
|
1730
|
+
if (typeof b !== "string") b = "";
|
|
1731
|
+
return str.replace(a, b);
|
|
1732
|
+
};
|
|
1733
|
+
var reverse = (str) => typeof str === "string" ? str.split("").reverse().join("") : "";
|
|
1734
|
+
var sentence = (str) => {
|
|
1735
|
+
if (typeof str !== "string") return "";
|
|
1736
|
+
return str.replace(
|
|
1737
|
+
/((?:\S[^.?!]*)[.?!]*)/g,
|
|
1738
|
+
(txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
|
|
1739
|
+
);
|
|
1740
|
+
};
|
|
1741
|
+
var snakecase = (str) => typeof str === "string" ? changecase(str, (ch) => `_${ch}`) : "";
|
|
1742
|
+
var trim = (str) => typeof str === "string" ? str.trim() : "";
|
|
1743
|
+
var trimLeft = (str) => typeof str === "string" ? str.replace(/^\s+/, "") : "";
|
|
1744
|
+
var trimRight = (str) => typeof str === "string" ? str.replace(/\s+$/, "") : "";
|
|
1745
|
+
var truncateWords = (str, count, suffix) => {
|
|
1746
|
+
if (typeof str === "string" && typeof count === "number" && Number.isFinite(count)) {
|
|
1747
|
+
if (typeof suffix !== "string") {
|
|
1748
|
+
suffix = "...";
|
|
1749
|
+
}
|
|
1750
|
+
const num = Math.trunc(count);
|
|
1751
|
+
let arr = str.split(" ");
|
|
1752
|
+
if (num < arr.length) {
|
|
1753
|
+
arr = arr.slice(0, num);
|
|
1754
|
+
}
|
|
1755
|
+
const val = arr.join(" ").trim();
|
|
1756
|
+
return val + suffix;
|
|
1569
1757
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
var
|
|
1574
|
-
"
|
|
1575
|
-
|
|
1576
|
-
var util = require("handlebars-utils");
|
|
1577
|
-
var path = require("path");
|
|
1578
|
-
var utils = require_utils2();
|
|
1579
|
-
var helpers3 = module2.exports;
|
|
1580
|
-
utils.expectedType = (variableName, expectedType, variableValue) => {
|
|
1581
|
-
const actualType = Object.prototype.toString.call(variableValue).slice(8, -1).toLowerCase();
|
|
1582
|
-
if (actualType !== expectedType) {
|
|
1583
|
-
throw new TypeError(`Expected ${variableName} to be of type ${expectedType}, but got ${actualType}`);
|
|
1584
|
-
}
|
|
1585
|
-
};
|
|
1586
|
-
helpers3.absolute = function(filepath, options) {
|
|
1587
|
-
options = options || { data: {} };
|
|
1588
|
-
var context = util.options(this, options);
|
|
1589
|
-
var ctx = Object.assign({}, options.data.root, context);
|
|
1590
|
-
var cwd = ctx.cwd || process.cwd();
|
|
1591
|
-
return path.resolve(cwd, filepath);
|
|
1592
|
-
};
|
|
1593
|
-
helpers3.dirname = function(filepath, options) {
|
|
1594
|
-
if (typeof filepath !== "string") {
|
|
1595
|
-
throw new TypeError(utils.expectedType("filepath", "string", filepath));
|
|
1596
|
-
}
|
|
1597
|
-
return path.dirname(filepath);
|
|
1598
|
-
};
|
|
1599
|
-
helpers3.relative = function(a, b) {
|
|
1600
|
-
if (typeof a !== "string") {
|
|
1601
|
-
throw new TypeError(utils.expectedType("first path", "string", a));
|
|
1602
|
-
}
|
|
1603
|
-
if (typeof b !== "string") {
|
|
1604
|
-
throw new TypeError(utils.expectedType("second path", "string", b));
|
|
1605
|
-
}
|
|
1606
|
-
return utils.relative(a, b);
|
|
1607
|
-
};
|
|
1608
|
-
helpers3.basename = function(filepath) {
|
|
1609
|
-
if (typeof filepath !== "string") {
|
|
1610
|
-
throw new TypeError(utils.expectedType("filepath", "string", filepath));
|
|
1611
|
-
}
|
|
1612
|
-
return path.basename(filepath);
|
|
1613
|
-
};
|
|
1614
|
-
helpers3.stem = function(filepath) {
|
|
1615
|
-
if (typeof filepath !== "string") {
|
|
1616
|
-
throw new TypeError(utils.expectedType("filepath", "string", filepath));
|
|
1617
|
-
}
|
|
1618
|
-
return path.basename(filepath, path.extname(filepath));
|
|
1619
|
-
};
|
|
1620
|
-
helpers3.extname = function(filepath) {
|
|
1621
|
-
if (typeof filepath !== "string") {
|
|
1622
|
-
throw new TypeError(utils.expectedType("filepath", "string", filepath));
|
|
1623
|
-
}
|
|
1624
|
-
return path.extname(filepath);
|
|
1625
|
-
};
|
|
1626
|
-
helpers3.resolve = function(filepath) {
|
|
1627
|
-
var args = [].slice.call(arguments);
|
|
1628
|
-
var opts = util.options(this, args.pop());
|
|
1629
|
-
var cwd = path.resolve(opts.cwd || process.cwd());
|
|
1630
|
-
args.unshift(cwd);
|
|
1631
|
-
return path.resolve.apply(path, args);
|
|
1632
|
-
};
|
|
1633
|
-
helpers3.segments = function(filepath, a, b) {
|
|
1634
|
-
if (typeof filepath !== "string") {
|
|
1635
|
-
throw new TypeError(utils.expectedType("filepath", "string", filepath));
|
|
1636
|
-
}
|
|
1637
|
-
var segments = filepath.split(/[\\\/]+/);
|
|
1638
|
-
return segments.slice(a, b).join("/");
|
|
1639
|
-
};
|
|
1758
|
+
return "";
|
|
1759
|
+
};
|
|
1760
|
+
var truncateWordsAlias = truncateWords;
|
|
1761
|
+
var uppercase = (str) => {
|
|
1762
|
+
if (typeof str === "object" && str !== null && "fn" in str && typeof str.fn === "function") {
|
|
1763
|
+
return String(str.fn()).toUpperCase();
|
|
1640
1764
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
var
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1765
|
+
if (typeof str !== "string") return "";
|
|
1766
|
+
return str.toUpperCase();
|
|
1767
|
+
};
|
|
1768
|
+
var upcase = (...args) => uppercase(...args);
|
|
1769
|
+
var helpers19 = [
|
|
1770
|
+
{
|
|
1771
|
+
name: "append",
|
|
1772
|
+
category: "string",
|
|
1773
|
+
compatibility: ["browser", "nodejs"],
|
|
1774
|
+
fn: append
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
name: "camelcase",
|
|
1778
|
+
category: "string",
|
|
1779
|
+
compatibility: ["browser", "nodejs"],
|
|
1780
|
+
fn: camelcase
|
|
1781
|
+
},
|
|
1782
|
+
{
|
|
1783
|
+
name: "capitalize",
|
|
1784
|
+
category: "string",
|
|
1785
|
+
compatibility: ["browser", "nodejs"],
|
|
1786
|
+
fn: capitalize
|
|
1787
|
+
},
|
|
1788
|
+
{
|
|
1789
|
+
name: "capitalizeAll",
|
|
1790
|
+
category: "string",
|
|
1791
|
+
compatibility: ["browser", "nodejs"],
|
|
1792
|
+
fn: capitalizeAll
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
name: "center",
|
|
1796
|
+
category: "string",
|
|
1797
|
+
compatibility: ["browser", "nodejs"],
|
|
1798
|
+
fn: center
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
name: "chop",
|
|
1802
|
+
category: "string",
|
|
1803
|
+
compatibility: ["browser", "nodejs"],
|
|
1804
|
+
fn: chopStr
|
|
1805
|
+
},
|
|
1806
|
+
{
|
|
1807
|
+
name: "dashcase",
|
|
1808
|
+
category: "string",
|
|
1809
|
+
compatibility: ["browser", "nodejs"],
|
|
1810
|
+
fn: dashcase
|
|
1811
|
+
},
|
|
1812
|
+
{
|
|
1813
|
+
name: "dotcase",
|
|
1814
|
+
category: "string",
|
|
1815
|
+
compatibility: ["browser", "nodejs"],
|
|
1816
|
+
fn: dotcase
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
name: "ellipsis",
|
|
1820
|
+
category: "string",
|
|
1821
|
+
compatibility: ["browser", "nodejs"],
|
|
1822
|
+
fn: ellipsis
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
name: "hyphenate",
|
|
1826
|
+
category: "string",
|
|
1827
|
+
compatibility: ["browser", "nodejs"],
|
|
1828
|
+
fn: hyphenate
|
|
1829
|
+
},
|
|
1830
|
+
{
|
|
1831
|
+
name: "isString",
|
|
1832
|
+
category: "string",
|
|
1833
|
+
compatibility: ["browser", "nodejs"],
|
|
1834
|
+
fn: isString
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
name: "lowercase",
|
|
1838
|
+
category: "string",
|
|
1839
|
+
compatibility: ["browser", "nodejs"],
|
|
1840
|
+
fn: lowercase
|
|
1841
|
+
},
|
|
1842
|
+
{
|
|
1843
|
+
name: "downcase",
|
|
1844
|
+
category: "string",
|
|
1845
|
+
compatibility: ["browser", "nodejs"],
|
|
1846
|
+
fn: downcase
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
name: "occurrences",
|
|
1850
|
+
category: "string",
|
|
1851
|
+
compatibility: ["browser", "nodejs"],
|
|
1852
|
+
fn: occurrences
|
|
1853
|
+
},
|
|
1854
|
+
{
|
|
1855
|
+
name: "pascalcase",
|
|
1856
|
+
category: "string",
|
|
1857
|
+
compatibility: ["browser", "nodejs"],
|
|
1858
|
+
fn: pascalcase
|
|
1859
|
+
},
|
|
1860
|
+
{
|
|
1861
|
+
name: "pathcase",
|
|
1862
|
+
category: "string",
|
|
1863
|
+
compatibility: ["browser", "nodejs"],
|
|
1864
|
+
fn: pathcase
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
name: "plusify",
|
|
1868
|
+
category: "string",
|
|
1869
|
+
compatibility: ["browser", "nodejs"],
|
|
1870
|
+
fn: plusify
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
name: "prepend",
|
|
1874
|
+
category: "string",
|
|
1875
|
+
compatibility: ["browser", "nodejs"],
|
|
1876
|
+
fn: prepend
|
|
1877
|
+
},
|
|
1878
|
+
{
|
|
1879
|
+
name: "remove",
|
|
1880
|
+
category: "string",
|
|
1881
|
+
compatibility: ["browser", "nodejs"],
|
|
1882
|
+
fn: remove
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
name: "removeFirst",
|
|
1886
|
+
category: "string",
|
|
1887
|
+
compatibility: ["browser", "nodejs"],
|
|
1888
|
+
fn: removeFirst
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
name: "replace",
|
|
1892
|
+
category: "string",
|
|
1893
|
+
compatibility: ["browser", "nodejs"],
|
|
1894
|
+
fn: replace
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
name: "replaceFirst",
|
|
1898
|
+
category: "string",
|
|
1899
|
+
compatibility: ["browser", "nodejs"],
|
|
1900
|
+
fn: replaceFirst
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
name: "reverse",
|
|
1904
|
+
category: "string",
|
|
1905
|
+
compatibility: ["browser", "nodejs"],
|
|
1906
|
+
fn: reverse
|
|
1907
|
+
},
|
|
1908
|
+
{
|
|
1909
|
+
name: "sentence",
|
|
1910
|
+
category: "string",
|
|
1911
|
+
compatibility: ["browser", "nodejs"],
|
|
1912
|
+
fn: sentence
|
|
1913
|
+
},
|
|
1914
|
+
{
|
|
1915
|
+
name: "snakecase",
|
|
1916
|
+
category: "string",
|
|
1917
|
+
compatibility: ["browser", "nodejs"],
|
|
1918
|
+
fn: snakecase
|
|
1919
|
+
},
|
|
1920
|
+
{
|
|
1921
|
+
name: "trim",
|
|
1922
|
+
category: "string",
|
|
1923
|
+
compatibility: ["browser", "nodejs"],
|
|
1924
|
+
fn: trim
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
name: "trimLeft",
|
|
1928
|
+
category: "string",
|
|
1929
|
+
compatibility: ["browser", "nodejs"],
|
|
1930
|
+
fn: trimLeft
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
name: "trimRight",
|
|
1934
|
+
category: "string",
|
|
1935
|
+
compatibility: ["browser", "nodejs"],
|
|
1936
|
+
fn: trimRight
|
|
1937
|
+
},
|
|
1938
|
+
{
|
|
1939
|
+
name: "truncate",
|
|
1940
|
+
category: "string",
|
|
1941
|
+
compatibility: ["browser", "nodejs"],
|
|
1942
|
+
fn: truncate
|
|
1943
|
+
},
|
|
1944
|
+
{
|
|
1945
|
+
name: "truncateWords",
|
|
1946
|
+
category: "string",
|
|
1947
|
+
compatibility: ["browser", "nodejs"],
|
|
1948
|
+
fn: truncateWordsAlias
|
|
1949
|
+
},
|
|
1950
|
+
{
|
|
1951
|
+
name: "uppercase",
|
|
1952
|
+
category: "string",
|
|
1953
|
+
compatibility: ["browser", "nodejs"],
|
|
1954
|
+
fn: uppercase
|
|
1955
|
+
},
|
|
1956
|
+
{
|
|
1957
|
+
name: "upcase",
|
|
1958
|
+
category: "string",
|
|
1959
|
+
compatibility: ["browser", "nodejs"],
|
|
1960
|
+
fn: upcase
|
|
1663
1961
|
}
|
|
1664
|
-
|
|
1962
|
+
];
|
|
1665
1963
|
|
|
1666
|
-
// helpers/
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
var helpers3 = module2.exports;
|
|
1674
|
-
helpers3.append = function(str, suffix) {
|
|
1675
|
-
if (typeof str === "string" && typeof suffix === "string") {
|
|
1676
|
-
return str + suffix;
|
|
1677
|
-
}
|
|
1678
|
-
return str;
|
|
1679
|
-
};
|
|
1680
|
-
helpers3.camelcase = function(str) {
|
|
1681
|
-
if (!util.isString(str)) return "";
|
|
1682
|
-
return utils.changecase(str, function(ch) {
|
|
1683
|
-
return ch.toUpperCase();
|
|
1684
|
-
});
|
|
1685
|
-
};
|
|
1686
|
-
helpers3.capitalize = function(str) {
|
|
1687
|
-
if (!util.isString(str)) return "";
|
|
1688
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1689
|
-
};
|
|
1690
|
-
helpers3.capitalizeAll = function(str) {
|
|
1691
|
-
if (!util.isString(str)) return "";
|
|
1692
|
-
if (util.isString(str)) {
|
|
1693
|
-
return str.replace(/\w\S*/g, function(word) {
|
|
1694
|
-
return helpers3.capitalize(word);
|
|
1695
|
-
});
|
|
1696
|
-
}
|
|
1697
|
-
};
|
|
1698
|
-
helpers3.center = function(str, spaces) {
|
|
1699
|
-
if (!util.isString(str)) return "";
|
|
1700
|
-
var space = "";
|
|
1701
|
-
var i = 0;
|
|
1702
|
-
while (i < spaces) {
|
|
1703
|
-
space += " ";
|
|
1704
|
-
i++;
|
|
1705
|
-
}
|
|
1706
|
-
return space + str + space;
|
|
1707
|
-
};
|
|
1708
|
-
helpers3.chop = function(str) {
|
|
1709
|
-
if (!util.isString(str)) return "";
|
|
1710
|
-
return utils.chop(str);
|
|
1711
|
-
};
|
|
1712
|
-
helpers3.dashcase = function(str) {
|
|
1713
|
-
if (!util.isString(str)) return "";
|
|
1714
|
-
return utils.changecase(str, function(ch) {
|
|
1715
|
-
return "-" + ch;
|
|
1716
|
-
});
|
|
1717
|
-
};
|
|
1718
|
-
helpers3.dotcase = function(str) {
|
|
1719
|
-
if (!util.isString(str)) return "";
|
|
1720
|
-
return utils.changecase(str, function(ch) {
|
|
1721
|
-
return "." + ch;
|
|
1722
|
-
});
|
|
1723
|
-
};
|
|
1724
|
-
helpers3.downcase = function() {
|
|
1725
|
-
return helpers3.lowercase.apply(this, arguments);
|
|
1726
|
-
};
|
|
1727
|
-
helpers3.ellipsis = function(str, limit) {
|
|
1728
|
-
if (util.isString(str)) {
|
|
1729
|
-
if (str.length <= limit) {
|
|
1730
|
-
return str;
|
|
1731
|
-
}
|
|
1732
|
-
return helpers3.truncate(str, limit) + "\u2026";
|
|
1733
|
-
}
|
|
1734
|
-
};
|
|
1735
|
-
helpers3.hyphenate = function(str) {
|
|
1736
|
-
if (!util.isString(str)) return "";
|
|
1737
|
-
return str.split(" ").join("-");
|
|
1738
|
-
};
|
|
1739
|
-
helpers3.isString = function(value) {
|
|
1740
|
-
return typeof value === "string";
|
|
1741
|
-
};
|
|
1742
|
-
helpers3.lowercase = function(str) {
|
|
1743
|
-
if (util.isObject(str) && str.fn) {
|
|
1744
|
-
return str.fn(this).toLowerCase();
|
|
1745
|
-
}
|
|
1746
|
-
if (!util.isString(str)) return "";
|
|
1747
|
-
return str.toLowerCase();
|
|
1748
|
-
};
|
|
1749
|
-
helpers3.occurrences = function(str, substring) {
|
|
1750
|
-
if (!util.isString(str)) return "";
|
|
1751
|
-
var len = substring.length;
|
|
1752
|
-
var pos = 0;
|
|
1753
|
-
var n = 0;
|
|
1754
|
-
while ((pos = str.indexOf(substring, pos)) > -1) {
|
|
1755
|
-
n++;
|
|
1756
|
-
pos += len;
|
|
1757
|
-
}
|
|
1758
|
-
return n;
|
|
1759
|
-
};
|
|
1760
|
-
helpers3.pascalcase = function(str) {
|
|
1761
|
-
if (!util.isString(str)) return "";
|
|
1762
|
-
str = utils.changecase(str, function(ch) {
|
|
1763
|
-
return ch.toUpperCase();
|
|
1764
|
-
});
|
|
1765
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1766
|
-
};
|
|
1767
|
-
helpers3.pathcase = function(str) {
|
|
1768
|
-
if (!util.isString(str)) return "";
|
|
1769
|
-
return utils.changecase(str, function(ch) {
|
|
1770
|
-
return "/" + ch;
|
|
1771
|
-
});
|
|
1772
|
-
};
|
|
1773
|
-
helpers3.plusify = function(str, ch) {
|
|
1774
|
-
if (!util.isString(str)) return "";
|
|
1775
|
-
if (!util.isString(ch)) ch = " ";
|
|
1776
|
-
return str.split(ch).join("+");
|
|
1777
|
-
};
|
|
1778
|
-
helpers3.prepend = function(str, prefix) {
|
|
1779
|
-
return typeof str === "string" && typeof prefix === "string" ? prefix + str : str;
|
|
1780
|
-
};
|
|
1781
|
-
helpers3.raw = function(options) {
|
|
1782
|
-
var str = options.fn();
|
|
1783
|
-
var opts = util.options(this, options);
|
|
1784
|
-
if (opts.escape !== false) {
|
|
1785
|
-
var idx = 0;
|
|
1786
|
-
while ((idx = str.indexOf("{{", idx)) !== -1) {
|
|
1787
|
-
if (str[idx - 1] !== "\\") {
|
|
1788
|
-
str = str.slice(0, idx) + "\\" + str.slice(idx);
|
|
1789
|
-
}
|
|
1790
|
-
idx += 3;
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
return str;
|
|
1794
|
-
};
|
|
1795
|
-
helpers3.remove = function(str, ch) {
|
|
1796
|
-
if (!util.isString(str)) return "";
|
|
1797
|
-
if (!util.isString(ch)) return str;
|
|
1798
|
-
return str.split(ch).join("");
|
|
1799
|
-
};
|
|
1800
|
-
helpers3.removeFirst = function(str, ch) {
|
|
1801
|
-
if (!util.isString(str)) return "";
|
|
1802
|
-
if (!util.isString(ch)) return str;
|
|
1803
|
-
return str.replace(ch, "");
|
|
1804
|
-
};
|
|
1805
|
-
helpers3.replace = function(str, a, b) {
|
|
1806
|
-
if (!util.isString(str)) return "";
|
|
1807
|
-
if (!util.isString(a)) return str;
|
|
1808
|
-
if (!util.isString(b)) b = "";
|
|
1809
|
-
return str.split(a).join(b);
|
|
1810
|
-
};
|
|
1811
|
-
helpers3.replaceFirst = function(str, a, b) {
|
|
1812
|
-
if (!util.isString(str)) return "";
|
|
1813
|
-
if (!util.isString(a)) return str;
|
|
1814
|
-
if (!util.isString(b)) b = "";
|
|
1815
|
-
return str.replace(a, b);
|
|
1816
|
-
};
|
|
1817
|
-
helpers3.reverse = function(str) {
|
|
1818
|
-
if (!util.isString(str)) return "";
|
|
1819
|
-
return str.split("").reverse().join("");
|
|
1820
|
-
};
|
|
1821
|
-
helpers3.sentence = function(str) {
|
|
1822
|
-
if (!util.isString(str)) return "";
|
|
1823
|
-
return str.replace(/((?:\S[^\.\?\!]*)[\.\?\!]*)/g, function(txt) {
|
|
1824
|
-
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
1825
|
-
});
|
|
1826
|
-
};
|
|
1827
|
-
helpers3.snakecase = function(str) {
|
|
1828
|
-
if (!util.isString(str)) return "";
|
|
1829
|
-
return utils.changecase(str, function(ch) {
|
|
1830
|
-
return "_" + ch;
|
|
1831
|
-
});
|
|
1832
|
-
};
|
|
1833
|
-
helpers3.split = function(str, ch) {
|
|
1834
|
-
if (!util.isString(str)) return "";
|
|
1835
|
-
if (!util.isString(ch)) ch = ",";
|
|
1836
|
-
return str.split(ch);
|
|
1837
|
-
};
|
|
1838
|
-
helpers3.startsWith = function(prefix, str, options) {
|
|
1839
|
-
var args = [].slice.call(arguments);
|
|
1840
|
-
options = args.pop();
|
|
1841
|
-
if (util.isString(str) && str.indexOf(prefix) === 0) {
|
|
1842
|
-
return options.fn(this);
|
|
1843
|
-
}
|
|
1844
|
-
if (typeof options.inverse === "function") {
|
|
1845
|
-
return options.inverse(this);
|
|
1846
|
-
}
|
|
1847
|
-
return "";
|
|
1848
|
-
};
|
|
1849
|
-
helpers3.titleize = function(str) {
|
|
1850
|
-
if (!util.isString(str)) return "";
|
|
1851
|
-
var title = str.replace(/[- _]+/g, " ");
|
|
1852
|
-
var words = title.split(" ");
|
|
1853
|
-
var len = words.length;
|
|
1854
|
-
var res = [];
|
|
1855
|
-
var i = 0;
|
|
1856
|
-
while (len--) {
|
|
1857
|
-
var word = words[i++];
|
|
1858
|
-
res.push(exports2.capitalize(word));
|
|
1859
|
-
}
|
|
1860
|
-
return res.join(" ");
|
|
1861
|
-
};
|
|
1862
|
-
helpers3.trim = function(str) {
|
|
1863
|
-
return typeof str === "string" ? str.trim() : "";
|
|
1864
|
-
};
|
|
1865
|
-
helpers3.trimLeft = function(str) {
|
|
1866
|
-
if (util.isString(str)) {
|
|
1867
|
-
return str.replace(/^\s+/, "");
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
helpers3.trimRight = function(str) {
|
|
1871
|
-
if (util.isString(str)) {
|
|
1872
|
-
return str.replace(/\s+$/, "");
|
|
1873
|
-
}
|
|
1874
|
-
};
|
|
1875
|
-
helpers3.truncate = function(str, limit, suffix) {
|
|
1876
|
-
if (util.isString(str)) {
|
|
1877
|
-
if (typeof suffix !== "string") {
|
|
1878
|
-
suffix = "";
|
|
1879
|
-
}
|
|
1880
|
-
if (str.length > limit) {
|
|
1881
|
-
return str.slice(0, limit - suffix.length) + suffix;
|
|
1882
|
-
}
|
|
1883
|
-
return str;
|
|
1884
|
-
}
|
|
1885
|
-
};
|
|
1886
|
-
helpers3.truncateWords = function(str, count, suffix) {
|
|
1887
|
-
if (util.isString(str) && isNumber(count)) {
|
|
1888
|
-
if (typeof suffix !== "string") {
|
|
1889
|
-
suffix = "...";
|
|
1890
|
-
}
|
|
1891
|
-
var num = Number(count);
|
|
1892
|
-
var arr = str.split(" ");
|
|
1893
|
-
if (num < arr.length) {
|
|
1894
|
-
arr = arr.slice(0, num);
|
|
1895
|
-
}
|
|
1896
|
-
var val = arr.join(" ").trim();
|
|
1897
|
-
return val + suffix;
|
|
1898
|
-
}
|
|
1899
|
-
};
|
|
1900
|
-
helpers3.upcase = function() {
|
|
1901
|
-
return helpers3.uppercase.apply(this, arguments);
|
|
1902
|
-
};
|
|
1903
|
-
helpers3.uppercase = function(str) {
|
|
1904
|
-
if (util.isObject(str) && str.fn) {
|
|
1905
|
-
return str.fn(this).toUpperCase();
|
|
1906
|
-
}
|
|
1907
|
-
if (!util.isString(str)) return "";
|
|
1908
|
-
return str.toUpperCase();
|
|
1909
|
-
};
|
|
1964
|
+
// src/helpers/url.ts
|
|
1965
|
+
import { escape as qsEscape } from "querystring";
|
|
1966
|
+
import { format, parse, resolve } from "url";
|
|
1967
|
+
var all = ["browser", "nodejs"];
|
|
1968
|
+
var encodeUri = (str) => {
|
|
1969
|
+
if (typeof str === "string") {
|
|
1970
|
+
return encodeURIComponent(str);
|
|
1910
1971
|
}
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
"helpers/lib/url.js"(exports2, module2) {
|
|
1916
|
-
"use strict";
|
|
1917
|
-
var url = require("url");
|
|
1918
|
-
var util = require("handlebars-utils");
|
|
1919
|
-
var querystring = require("querystring");
|
|
1920
|
-
var helpers3 = module2.exports;
|
|
1921
|
-
helpers3.encodeURI = function(str) {
|
|
1922
|
-
if (util.isString(str)) {
|
|
1923
|
-
return encodeURIComponent(str);
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
helpers3.escape = function(str) {
|
|
1927
|
-
if (util.isString(str)) {
|
|
1928
|
-
return querystring.escape(str);
|
|
1929
|
-
}
|
|
1930
|
-
};
|
|
1931
|
-
helpers3.decodeURI = function(str) {
|
|
1932
|
-
if (util.isString(str)) {
|
|
1933
|
-
return decodeURIComponent(str);
|
|
1934
|
-
}
|
|
1935
|
-
};
|
|
1936
|
-
helpers3.url_encode = function() {
|
|
1937
|
-
return helpers3.encodeURI.apply(this, arguments);
|
|
1938
|
-
};
|
|
1939
|
-
helpers3.url_decode = function(val) {
|
|
1940
|
-
return helpers3.decodeURI.apply(this, arguments);
|
|
1941
|
-
};
|
|
1942
|
-
helpers3.urlResolve = function(base, href) {
|
|
1943
|
-
return url.resolve(base, href);
|
|
1944
|
-
};
|
|
1945
|
-
helpers3.urlParse = function(str) {
|
|
1946
|
-
return url.parse(str);
|
|
1947
|
-
};
|
|
1948
|
-
helpers3.stripQuerystring = function(str) {
|
|
1949
|
-
if (util.isString(str)) {
|
|
1950
|
-
return str.split("?")[0];
|
|
1951
|
-
}
|
|
1952
|
-
};
|
|
1953
|
-
helpers3.stripProtocol = function(str) {
|
|
1954
|
-
if (util.isString(str)) {
|
|
1955
|
-
var parsed = url.parse(str);
|
|
1956
|
-
parsed.protocol = "";
|
|
1957
|
-
return parsed.format();
|
|
1958
|
-
}
|
|
1959
|
-
};
|
|
1972
|
+
};
|
|
1973
|
+
var escapeFn = (str) => {
|
|
1974
|
+
if (typeof str === "string") {
|
|
1975
|
+
return qsEscape(str);
|
|
1960
1976
|
}
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
"helpers/lib/index.js"(exports2, module2) {
|
|
1966
|
-
"use strict";
|
|
1967
|
-
module2.exports = {
|
|
1968
|
-
array: require_array(),
|
|
1969
|
-
code: require_code(),
|
|
1970
|
-
collection: require_collection(),
|
|
1971
|
-
comparison: require_comparison(),
|
|
1972
|
-
date: require_date(),
|
|
1973
|
-
fs: require_fs(),
|
|
1974
|
-
html: require_html2(),
|
|
1975
|
-
i18n: require_i18n(),
|
|
1976
|
-
inflection: require_inflection(),
|
|
1977
|
-
logging: require_logging(),
|
|
1978
|
-
markdown: require_markdown(),
|
|
1979
|
-
match: require_match(),
|
|
1980
|
-
math: require_math(),
|
|
1981
|
-
misc: require_misc(),
|
|
1982
|
-
number: require_number(),
|
|
1983
|
-
object: require_object(),
|
|
1984
|
-
path: require_path(),
|
|
1985
|
-
regex: require_regex(),
|
|
1986
|
-
string: require_string(),
|
|
1987
|
-
url: require_url()
|
|
1988
|
-
};
|
|
1977
|
+
};
|
|
1978
|
+
var decodeUri = (str) => {
|
|
1979
|
+
if (typeof str === "string") {
|
|
1980
|
+
return decodeURIComponent(str);
|
|
1989
1981
|
}
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
} else if (!Array.isArray(groups)) {
|
|
2003
|
-
options = groups;
|
|
2004
|
-
groups = null;
|
|
2005
|
-
}
|
|
2006
|
-
options = options || {};
|
|
2007
|
-
var hbs = options.handlebars || options.hbs || require("handlebars");
|
|
2008
|
-
define(module2.exports, "handlebars", hbs);
|
|
2009
|
-
if (groups) {
|
|
2010
|
-
groups.forEach(function(key) {
|
|
2011
|
-
hbs.registerHelper(lib[key]);
|
|
2012
|
-
});
|
|
2013
|
-
} else {
|
|
2014
|
-
forIn(lib, function(group, key) {
|
|
2015
|
-
hbs.registerHelper(group);
|
|
2016
|
-
});
|
|
2017
|
-
}
|
|
2018
|
-
return hbs.helpers;
|
|
2019
|
-
};
|
|
2020
|
-
forIn(lib, function(group, key) {
|
|
2021
|
-
define(module2.exports, key, function(options) {
|
|
2022
|
-
options = options || {};
|
|
2023
|
-
var hbs = options.handlebars || options.hbs || require("handlebars");
|
|
2024
|
-
define(module2.exports, "handlebars", hbs);
|
|
2025
|
-
hbs.registerHelper(group);
|
|
2026
|
-
return hbs.helpers;
|
|
2027
|
-
});
|
|
2028
|
-
});
|
|
2029
|
-
module2.exports.utils = require_utils2();
|
|
1982
|
+
};
|
|
1983
|
+
function urlEncode(...args) {
|
|
1984
|
+
return encodeUri.apply(this, args);
|
|
1985
|
+
}
|
|
1986
|
+
function urlDecode(...args) {
|
|
1987
|
+
return decodeUri.apply(this, args);
|
|
1988
|
+
}
|
|
1989
|
+
var urlResolve = (base, href) => resolve(String(base), String(href));
|
|
1990
|
+
var urlParse = (str) => parse(String(str));
|
|
1991
|
+
var stripQuerystring = (str) => {
|
|
1992
|
+
if (typeof str === "string") {
|
|
1993
|
+
return str.split("?")[0];
|
|
2030
1994
|
}
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
HelperRegistry: () => HelperRegistry,
|
|
2038
|
-
createHandlebars: () => createHandlebars,
|
|
2039
|
-
fumanchu: () => fumanchu,
|
|
2040
|
-
handlebars: () => handlebars,
|
|
2041
|
-
helpers: () => helpers2
|
|
2042
|
-
});
|
|
2043
|
-
module.exports = __toCommonJS(index_exports);
|
|
2044
|
-
var HandlebarsLib = __toESM(require("handlebars"));
|
|
2045
|
-
|
|
2046
|
-
// src/helpers/date.ts
|
|
2047
|
-
var import_chrono_node = require("chrono-node");
|
|
2048
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
2049
|
-
var year = () => (/* @__PURE__ */ new Date()).getFullYear().toString();
|
|
2050
|
-
var date = (humanReadableDate, formatString) => {
|
|
2051
|
-
const parsedDate = (0, import_chrono_node.parseDate)(humanReadableDate);
|
|
2052
|
-
if (!parsedDate) {
|
|
2053
|
-
throw new Error(`Unable to parse date: ${humanReadableDate}`);
|
|
1995
|
+
};
|
|
1996
|
+
var stripProtocol = (str) => {
|
|
1997
|
+
if (typeof str === "string") {
|
|
1998
|
+
const parsed = parse(str);
|
|
1999
|
+
parsed.protocol = "";
|
|
2000
|
+
return format(parsed);
|
|
2054
2001
|
}
|
|
2055
|
-
return (0, import_dayjs.default)(parsedDate).format(formatString);
|
|
2056
2002
|
};
|
|
2057
|
-
var
|
|
2003
|
+
var helpers20 = [
|
|
2058
2004
|
{
|
|
2059
|
-
name: "
|
|
2060
|
-
category: "
|
|
2061
|
-
|
|
2005
|
+
name: "encodeURI",
|
|
2006
|
+
category: "url",
|
|
2007
|
+
compatibility: all,
|
|
2008
|
+
fn: encodeUri
|
|
2062
2009
|
},
|
|
2063
2010
|
{
|
|
2064
|
-
name: "
|
|
2065
|
-
category: "
|
|
2066
|
-
|
|
2011
|
+
name: "escape",
|
|
2012
|
+
category: "url",
|
|
2013
|
+
compatibility: ["nodejs"],
|
|
2014
|
+
fn: escapeFn
|
|
2067
2015
|
},
|
|
2068
2016
|
{
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
fn:
|
|
2017
|
+
name: "decodeURI",
|
|
2018
|
+
category: "url",
|
|
2019
|
+
compatibility: all,
|
|
2020
|
+
fn: decodeUri
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
name: "url_encode",
|
|
2024
|
+
category: "url",
|
|
2025
|
+
compatibility: all,
|
|
2026
|
+
fn: urlEncode
|
|
2027
|
+
},
|
|
2028
|
+
{
|
|
2029
|
+
name: "url_decode",
|
|
2030
|
+
category: "url",
|
|
2031
|
+
compatibility: all,
|
|
2032
|
+
fn: urlDecode
|
|
2033
|
+
},
|
|
2034
|
+
{
|
|
2035
|
+
name: "urlResolve",
|
|
2036
|
+
category: "url",
|
|
2037
|
+
compatibility: ["nodejs"],
|
|
2038
|
+
fn: urlResolve
|
|
2039
|
+
},
|
|
2040
|
+
{
|
|
2041
|
+
name: "urlParse",
|
|
2042
|
+
category: "url",
|
|
2043
|
+
compatibility: ["nodejs"],
|
|
2044
|
+
fn: urlParse
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
name: "stripQuerystring",
|
|
2048
|
+
category: "url",
|
|
2049
|
+
compatibility: all,
|
|
2050
|
+
fn: stripQuerystring
|
|
2051
|
+
},
|
|
2052
|
+
{
|
|
2053
|
+
name: "stripProtocol",
|
|
2054
|
+
category: "url",
|
|
2055
|
+
compatibility: ["nodejs"],
|
|
2056
|
+
fn: stripProtocol
|
|
2073
2057
|
}
|
|
2074
2058
|
];
|
|
2075
2059
|
|
|
2076
2060
|
// src/helper-registry.ts
|
|
2077
2061
|
var HelperRegistry = class {
|
|
2062
|
+
_helpers = [];
|
|
2078
2063
|
constructor() {
|
|
2079
|
-
this._helpers = [];
|
|
2080
2064
|
this.init();
|
|
2081
2065
|
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Get all registered helpers.
|
|
2068
|
+
* @returns {Helper[]} The array of registered helpers.
|
|
2069
|
+
*/
|
|
2070
|
+
get helpers() {
|
|
2071
|
+
return this._helpers;
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* Initialize the helper registry. This is performed during the construction of the registry such as new HelperRegistry().
|
|
2075
|
+
*/
|
|
2082
2076
|
init() {
|
|
2083
2077
|
this.registerHelpers(helpers);
|
|
2078
|
+
this.registerHelpers(helpers3);
|
|
2079
|
+
this.registerHelpers(helpers5);
|
|
2080
|
+
this.registerHelpers(helpers6);
|
|
2081
|
+
this.registerHelpers(helpers2);
|
|
2082
|
+
this.registerHelpers(helpers13);
|
|
2083
|
+
this.registerHelpers(helpers7);
|
|
2084
|
+
this.registerHelpers(helpers4);
|
|
2085
|
+
this.registerHelpers(helpers8);
|
|
2086
|
+
this.registerHelpers(helpers9);
|
|
2087
|
+
this.registerHelpers(helpers10);
|
|
2088
|
+
this.registerHelpers(helpers11);
|
|
2089
|
+
this.registerHelpers(helpers12);
|
|
2090
|
+
this.registerHelpers(helpers14);
|
|
2091
|
+
this.registerHelpers(helpers15);
|
|
2092
|
+
this.registerHelpers(helpers17);
|
|
2093
|
+
this.registerHelpers(helpers18);
|
|
2094
|
+
this.registerHelpers(helpers19);
|
|
2095
|
+
this.registerHelpers(helpers20);
|
|
2096
|
+
this.registerHelpers(helpers16);
|
|
2084
2097
|
}
|
|
2098
|
+
/**
|
|
2099
|
+
* Register a helper.
|
|
2100
|
+
* @param {Helper} helper The helper to register.
|
|
2101
|
+
* @returns True if the helper was registered, false otherwise.
|
|
2102
|
+
*/
|
|
2085
2103
|
register(helper) {
|
|
2086
2104
|
const result = false;
|
|
2087
2105
|
if (!this.has(helper.name)) {
|
|
@@ -2089,23 +2107,65 @@ var HelperRegistry = class {
|
|
|
2089
2107
|
}
|
|
2090
2108
|
return result;
|
|
2091
2109
|
}
|
|
2092
|
-
|
|
2093
|
-
|
|
2110
|
+
/**
|
|
2111
|
+
* Register multiple helpers.
|
|
2112
|
+
* @param {Helper[]} helpers The array of helpers to register.
|
|
2113
|
+
*/
|
|
2114
|
+
registerHelpers(helpers22) {
|
|
2115
|
+
for (const helper of helpers22) {
|
|
2094
2116
|
this.register(helper);
|
|
2095
2117
|
}
|
|
2096
2118
|
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Check if a helper is registered.
|
|
2121
|
+
* @param name The name of the helper.
|
|
2122
|
+
* @returns True if the helper is registered, false otherwise.
|
|
2123
|
+
*/
|
|
2097
2124
|
has(name) {
|
|
2098
2125
|
return this._helpers.some((helper) => helper.name === name);
|
|
2099
2126
|
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Filter helpers by the given criteria.
|
|
2129
|
+
* @param filter The filter criteria.
|
|
2130
|
+
* @returns The filtered helpers.
|
|
2131
|
+
*/
|
|
2100
2132
|
filter(filter) {
|
|
2101
|
-
|
|
2133
|
+
let result = this._helpers;
|
|
2134
|
+
if (filter.names) {
|
|
2135
|
+
result = result.filter((helper) => filter.names?.includes(helper.name));
|
|
2136
|
+
}
|
|
2137
|
+
if (filter.categories) {
|
|
2138
|
+
result = result.filter(
|
|
2139
|
+
(helper) => filter.categories?.includes(helper.category)
|
|
2140
|
+
);
|
|
2141
|
+
}
|
|
2142
|
+
if (filter.compatibility) {
|
|
2143
|
+
result = result.filter(
|
|
2144
|
+
(helper) => helper.compatibility?.some((c) => filter.compatibility?.includes(c))
|
|
2145
|
+
);
|
|
2146
|
+
}
|
|
2147
|
+
return result;
|
|
2102
2148
|
}
|
|
2103
|
-
|
|
2104
|
-
|
|
2149
|
+
/**
|
|
2150
|
+
* Load Handlebars helpers.
|
|
2151
|
+
* @param {Handlebars} handlebars The Handlebars instance.
|
|
2152
|
+
* @returns {void}
|
|
2153
|
+
*/
|
|
2154
|
+
load(handlebars2, filters) {
|
|
2155
|
+
let helpers22 = this._helpers;
|
|
2156
|
+
if (filters) {
|
|
2157
|
+
helpers22 = this.filter(filters);
|
|
2158
|
+
}
|
|
2159
|
+
for (const helper of helpers22) {
|
|
2105
2160
|
handlebars2.registerHelper(helper.name, helper.fn);
|
|
2106
2161
|
}
|
|
2107
2162
|
}
|
|
2108
|
-
|
|
2163
|
+
/**
|
|
2164
|
+
* Swap Handlebars helpers. This is used when you want to swap out legacy helpers for fumanchu helpers.
|
|
2165
|
+
* @param handlebars The Handlebars instance.
|
|
2166
|
+
* @returns {void}
|
|
2167
|
+
*/
|
|
2168
|
+
swap(handlebars2) {
|
|
2109
2169
|
for (const helper of this._helpers) {
|
|
2110
2170
|
handlebars2.unregisterHelper(helper.name);
|
|
2111
2171
|
handlebars2.registerHelper(helper.name, helper.fn);
|
|
@@ -2114,44 +2174,37 @@ var HelperRegistry = class {
|
|
|
2114
2174
|
};
|
|
2115
2175
|
|
|
2116
2176
|
// src/index.ts
|
|
2117
|
-
var
|
|
2118
|
-
var Handlebars = HandlebarsLib;
|
|
2177
|
+
var Handlebars2 = HandlebarsLib;
|
|
2119
2178
|
var handlebars = HandlebarsLib.create();
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
const registry = new HelperRegistry();
|
|
2124
|
-
const handlebars2 = HandlebarsLib.create();
|
|
2125
|
-
const helpersFunction = yield import_helpers.default;
|
|
2126
|
-
helpersFunction({ handlebars: handlebars2 });
|
|
2127
|
-
registry.swapHelpers(handlebars2);
|
|
2128
|
-
return handlebars2;
|
|
2129
|
-
});
|
|
2179
|
+
function helpers21(options) {
|
|
2180
|
+
const registry = new HelperRegistry();
|
|
2181
|
+
registry.load(options.handlebars ?? options.hbs);
|
|
2130
2182
|
}
|
|
2131
|
-
function
|
|
2183
|
+
async function createHandlebars() {
|
|
2132
2184
|
const registry = new HelperRegistry();
|
|
2133
2185
|
const handlebars2 = HandlebarsLib.create();
|
|
2134
|
-
registry.
|
|
2186
|
+
registry.load(handlebars2);
|
|
2187
|
+
if (process.env.NODE_ENV === "development") {
|
|
2188
|
+
console.warn(
|
|
2189
|
+
"createHandlebars will be deprecated in future versions, use `fumanchu` instead."
|
|
2190
|
+
);
|
|
2191
|
+
}
|
|
2192
|
+
return handlebars2;
|
|
2193
|
+
}
|
|
2194
|
+
function fumanchu(options) {
|
|
2195
|
+
const registry = new HelperRegistry();
|
|
2196
|
+
let handlebars2 = HandlebarsLib.create();
|
|
2197
|
+
if (options?.handlebars) {
|
|
2198
|
+
handlebars2 = options.handlebars;
|
|
2199
|
+
}
|
|
2200
|
+
registry.load(handlebars2);
|
|
2135
2201
|
return handlebars2;
|
|
2136
2202
|
}
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
Handlebars,
|
|
2203
|
+
export {
|
|
2204
|
+
Handlebars2 as Handlebars,
|
|
2140
2205
|
HelperRegistry,
|
|
2141
2206
|
createHandlebars,
|
|
2142
2207
|
fumanchu,
|
|
2143
2208
|
handlebars,
|
|
2144
|
-
helpers
|
|
2145
|
-
}
|
|
2146
|
-
/*!
|
|
2147
|
-
* helper-markdown <https://github.com/jonschlinkert/helper-markdown>
|
|
2148
|
-
*
|
|
2149
|
-
* Copyright (c) 2014 Jon Schlinkert, contributors.
|
|
2150
|
-
* Licensed under the MIT license.
|
|
2151
|
-
*/
|
|
2152
|
-
/*!
|
|
2153
|
-
* handlebars-helpers <https://github.com/helpers/handlebars-helpers>
|
|
2154
|
-
*
|
|
2155
|
-
* Copyright (c) 2013-2017, Jon Schlinkert, Brian Woodward.
|
|
2156
|
-
* Released under the MIT License.
|
|
2157
|
-
*/
|
|
2209
|
+
helpers21 as helpers
|
|
2210
|
+
};
|