express-sweet 1.0.36 → 1.0.38
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/CHANGELOG.md +28 -2
- package/dist/build.common.js +8 -8
- package/dist/build.esm.js +7 -7
- package/docs/index.html +281 -3
- package/package.json +1 -1
- package/types/handlebars_helpers/index.d.ts +2 -1
- package/types/handlebars_helpers/math.d.ts +81 -0
- package/types/interfaces/ViewConfig.d.ts +2 -2
- package/types/middlewares/Authentication.d.ts +1 -1
- package/types/middlewares/View.d.ts +4 -0
package/docs/index.html
CHANGED
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
<!--begin::Title-->
|
|
82
82
|
<h1 class="page-heading d-flex text-dark fw-bold fs-3 justify-content-center align-items-baseline my-0">
|
|
83
83
|
<!-- <h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0"> -->
|
|
84
|
-
DevDocs<a href="#changelog" class="badge fw-semibold fs-7 px-2 ms-2 bg-body text-dark text-hover-primary shadow-sm">v1.0.
|
|
84
|
+
DevDocs<a href="#changelog" class="badge fw-semibold fs-7 px-2 ms-2 bg-body text-dark text-hover-primary shadow-sm">v1.0.38</a>
|
|
85
85
|
</h1>
|
|
86
86
|
<!--end::Title-->
|
|
87
87
|
</div>
|
|
@@ -481,6 +481,18 @@
|
|
|
481
481
|
<!--end:Menu link-->
|
|
482
482
|
</div>
|
|
483
483
|
<!--end:Menu item-->
|
|
484
|
+
<!--begin:Menu item-->
|
|
485
|
+
<div class="menu-item">
|
|
486
|
+
<!--begin:Menu link-->
|
|
487
|
+
<a class="menu-link" href="#view-math-helper">
|
|
488
|
+
<span class="menu-bullet">
|
|
489
|
+
<span class="bullet bullet-dot"></span>
|
|
490
|
+
</span>
|
|
491
|
+
<span class="menu-title">Math Helper</span>
|
|
492
|
+
</a>
|
|
493
|
+
<!--end:Menu link-->
|
|
494
|
+
</div>
|
|
495
|
+
<!--end:Menu item-->
|
|
484
496
|
</div>
|
|
485
497
|
<!--end:Menu sub-->
|
|
486
498
|
</div>
|
|
@@ -1855,7 +1867,7 @@ module.exports = router;</code></pre>
|
|
|
1855
1867
|
<td>Extension for templates and partials files.<br>The default is <code>.hbs</code>.</td>
|
|
1856
1868
|
</tr>
|
|
1857
1869
|
<tr>
|
|
1858
|
-
<td class="w-250px"><code>beforeRender: (req: express.Request, res: express.Response) => void</code></td>
|
|
1870
|
+
<td class="w-250px"><code>beforeRender: (req: express.Request, res: express.Response) => Promise<void>|void</code></td>
|
|
1859
1871
|
<td>
|
|
1860
1872
|
Hook function just before the view is rendered.<br>
|
|
1861
1873
|
For example, you can set your own local variables that can be used within the view.<br>
|
|
@@ -1875,7 +1887,7 @@ module.exports = router;</code></pre>
|
|
|
1875
1887
|
* res.locals.message = 'Hello World';
|
|
1876
1888
|
* }
|
|
1877
1889
|
*
|
|
1878
|
-
* @type {(res: express.Response) => void}
|
|
1890
|
+
* @type {(res: express.Response) => Promise<void>|void}
|
|
1879
1891
|
*/
|
|
1880
1892
|
beforeRender: (req, res) => {
|
|
1881
1893
|
res.locals.message = 'Hello World';
|
|
@@ -3293,6 +3305,272 @@ Else
|
|
|
3293
3305
|
<!--end::Table wrapper-->
|
|
3294
3306
|
</div>
|
|
3295
3307
|
<!--end::Table-->
|
|
3308
|
+
|
|
3309
|
+
|
|
3310
|
+
|
|
3311
|
+
|
|
3312
|
+
<!--begin::Block-->
|
|
3313
|
+
<h2 id="view-math-helper" class="text-gray-700 py-5 fw-normal">Math Helper</h2>
|
|
3314
|
+
<!--end::Block-->
|
|
3315
|
+
<!--begin::Table-->
|
|
3316
|
+
<div class="py-2">
|
|
3317
|
+
<!--begin::Table wrapper-->
|
|
3318
|
+
<div class="table-responsive border rounded">
|
|
3319
|
+
<!--begin::Table-->
|
|
3320
|
+
<table class="table table-striped mb-0 g-6">
|
|
3321
|
+
<!--begin::Head-->
|
|
3322
|
+
<thead>
|
|
3323
|
+
<tr class="fs-4 fw-bold p-6">
|
|
3324
|
+
<th class="min-w-200px">Function</th>
|
|
3325
|
+
<th>Description</th>
|
|
3326
|
+
</tr>
|
|
3327
|
+
</thead>
|
|
3328
|
+
<!--end::Head-->
|
|
3329
|
+
<!--begin::Body-->
|
|
3330
|
+
<tbody>
|
|
3331
|
+
<tr>
|
|
3332
|
+
<td class="w-250px"><code>add()</code></td>
|
|
3333
|
+
<td>
|
|
3334
|
+
Calculates the sum of two numbers.
|
|
3335
|
+
<!--begin::Parameters-->
|
|
3336
|
+
<div class="py-5">
|
|
3337
|
+
<p>Parameters:</p>
|
|
3338
|
+
<ul>
|
|
3339
|
+
<li><code>val1: number|string</code> The first number.</li>
|
|
3340
|
+
<li><code>val2: number|string</code> The second number.</li>
|
|
3341
|
+
</ul>
|
|
3342
|
+
</div>
|
|
3343
|
+
<!--end::Parameters-->
|
|
3344
|
+
<!--begin::Return value-->
|
|
3345
|
+
<div class="py-5">
|
|
3346
|
+
<p>Return value:</p>
|
|
3347
|
+
<code>number</code>
|
|
3348
|
+
</div>
|
|
3349
|
+
<!--end::Return value-->
|
|
3350
|
+
<!--begin::Code-->
|
|
3351
|
+
<div class="py-5">
|
|
3352
|
+
<!--begin::Highlight-->
|
|
3353
|
+
<div class="highlight">
|
|
3354
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3355
|
+
<div class="highlight-code">
|
|
3356
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 3 --}}
|
|
3357
|
+
{{add 1 2}}</code></pre>
|
|
3358
|
+
</div>
|
|
3359
|
+
</div>
|
|
3360
|
+
<!--end::Highlight-->
|
|
3361
|
+
</div>
|
|
3362
|
+
<!--end::Code-->
|
|
3363
|
+
</td>
|
|
3364
|
+
</tr>
|
|
3365
|
+
<tr>
|
|
3366
|
+
<td class="w-250px"><code>sub()</code></td>
|
|
3367
|
+
<td>
|
|
3368
|
+
Calculates the difference of the given values.
|
|
3369
|
+
<!--begin::Parameters-->
|
|
3370
|
+
<div class="py-5">
|
|
3371
|
+
<p>Parameters:</p>
|
|
3372
|
+
<ul>
|
|
3373
|
+
<li><code>val1: number|string</code> The first number.</li>
|
|
3374
|
+
<li><code>val2: number|string</code> The second number.</li>
|
|
3375
|
+
</ul>
|
|
3376
|
+
</div>
|
|
3377
|
+
<!--end::Parameters-->
|
|
3378
|
+
<!--begin::Return value-->
|
|
3379
|
+
<div class="py-5">
|
|
3380
|
+
<p>Return value:</p>
|
|
3381
|
+
<code>number</code>
|
|
3382
|
+
</div>
|
|
3383
|
+
<!--end::Return value-->
|
|
3384
|
+
<!--begin::Code-->
|
|
3385
|
+
<div class="py-5">
|
|
3386
|
+
<!--begin::Highlight-->
|
|
3387
|
+
<div class="highlight">
|
|
3388
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3389
|
+
<div class="highlight-code">
|
|
3390
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 3 --}}
|
|
3391
|
+
{{sub 5 2}}</code></pre>
|
|
3392
|
+
</div>
|
|
3393
|
+
</div>
|
|
3394
|
+
<!--end::Highlight-->
|
|
3395
|
+
</div>
|
|
3396
|
+
<!--end::Code-->
|
|
3397
|
+
</td>
|
|
3398
|
+
</tr>
|
|
3399
|
+
<tr>
|
|
3400
|
+
<td class="w-250px"><code>multiply()</code></td>
|
|
3401
|
+
<td>
|
|
3402
|
+
Calculate the multiplication of the given values.
|
|
3403
|
+
<!--begin::Parameters-->
|
|
3404
|
+
<div class="py-5">
|
|
3405
|
+
<p>Parameters:</p>
|
|
3406
|
+
<ul>
|
|
3407
|
+
<li><code>val1: number|string</code> The first number.</li>
|
|
3408
|
+
<li><code>val2: number|string</code> The second number.</li>
|
|
3409
|
+
</ul>
|
|
3410
|
+
</div>
|
|
3411
|
+
<!--end::Parameters-->
|
|
3412
|
+
<!--begin::Return value-->
|
|
3413
|
+
<div class="py-5">
|
|
3414
|
+
<p>Return value:</p>
|
|
3415
|
+
<code>number</code>
|
|
3416
|
+
</div>
|
|
3417
|
+
<!--end::Return value-->
|
|
3418
|
+
<!--begin::Code-->
|
|
3419
|
+
<div class="py-5">
|
|
3420
|
+
<!--begin::Highlight-->
|
|
3421
|
+
<div class="highlight">
|
|
3422
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3423
|
+
<div class="highlight-code">
|
|
3424
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 10 --}}
|
|
3425
|
+
{{multiply 5 2}}</code></pre>
|
|
3426
|
+
</div>
|
|
3427
|
+
</div>
|
|
3428
|
+
<!--end::Highlight-->
|
|
3429
|
+
</div>
|
|
3430
|
+
<!--end::Code-->
|
|
3431
|
+
</td>
|
|
3432
|
+
</tr>
|
|
3433
|
+
<tr>
|
|
3434
|
+
<td class="w-250px"><code>divide()</code></td>
|
|
3435
|
+
<td>
|
|
3436
|
+
Compute the division of the given values.
|
|
3437
|
+
<!--begin::Parameters-->
|
|
3438
|
+
<div class="py-5">
|
|
3439
|
+
<p>Parameters:</p>
|
|
3440
|
+
<ul>
|
|
3441
|
+
<li><code>val1: number|string</code> The first number.</li>
|
|
3442
|
+
<li><code>val2: number|string</code> The second number.</li>
|
|
3443
|
+
</ul>
|
|
3444
|
+
</div>
|
|
3445
|
+
<!--end::Parameters-->
|
|
3446
|
+
<!--begin::Return value-->
|
|
3447
|
+
<div class="py-5">
|
|
3448
|
+
<p>Return value:</p>
|
|
3449
|
+
<code>number</code>
|
|
3450
|
+
</div>
|
|
3451
|
+
<!--end::Return value-->
|
|
3452
|
+
<!--begin::Code-->
|
|
3453
|
+
<div class="py-5">
|
|
3454
|
+
<!--begin::Highlight-->
|
|
3455
|
+
<div class="highlight">
|
|
3456
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3457
|
+
<div class="highlight-code">
|
|
3458
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 5 --}}
|
|
3459
|
+
{{divide 10 2}}</code></pre>
|
|
3460
|
+
</div>
|
|
3461
|
+
</div>
|
|
3462
|
+
<!--end::Highlight-->
|
|
3463
|
+
</div>
|
|
3464
|
+
<!--end::Code-->
|
|
3465
|
+
</td>
|
|
3466
|
+
</tr>
|
|
3467
|
+
<tr>
|
|
3468
|
+
<td class="w-250px"><code>ceil()</code></td>
|
|
3469
|
+
<td>
|
|
3470
|
+
Round up the value.
|
|
3471
|
+
<!--begin::Parameters-->
|
|
3472
|
+
<div class="py-5">
|
|
3473
|
+
<p>Parameters:</p>
|
|
3474
|
+
<ul>
|
|
3475
|
+
<li><code>val: number|string</code> Number to be rounded to nearest greater integer.</li>
|
|
3476
|
+
</ul>
|
|
3477
|
+
</div>
|
|
3478
|
+
<!--end::Parameters-->
|
|
3479
|
+
<!--begin::Return value-->
|
|
3480
|
+
<div class="py-5">
|
|
3481
|
+
<p>Return value:</p>
|
|
3482
|
+
<code>number</code>
|
|
3483
|
+
</div>
|
|
3484
|
+
<!--end::Return value-->
|
|
3485
|
+
<!--begin::Code-->
|
|
3486
|
+
<div class="py-5">
|
|
3487
|
+
<!--begin::Highlight-->
|
|
3488
|
+
<div class="highlight">
|
|
3489
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3490
|
+
<div class="highlight-code">
|
|
3491
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 6 --}}
|
|
3492
|
+
{{ceil 5.6}}</code></pre>
|
|
3493
|
+
</div>
|
|
3494
|
+
</div>
|
|
3495
|
+
<!--end::Highlight-->
|
|
3496
|
+
</div>
|
|
3497
|
+
<!--end::Code-->
|
|
3498
|
+
</td>
|
|
3499
|
+
</tr>
|
|
3500
|
+
<tr>
|
|
3501
|
+
<td class="w-250px"><code>floor()</code></td>
|
|
3502
|
+
<td>
|
|
3503
|
+
Rounds down a number.
|
|
3504
|
+
<!--begin::Parameters-->
|
|
3505
|
+
<div class="py-5">
|
|
3506
|
+
<p>Parameters:</p>
|
|
3507
|
+
<ul>
|
|
3508
|
+
<li><code>val: number|string</code> Number to be rounded to nearest lower integer.</li>
|
|
3509
|
+
</ul>
|
|
3510
|
+
</div>
|
|
3511
|
+
<!--end::Parameters-->
|
|
3512
|
+
<!--begin::Return value-->
|
|
3513
|
+
<div class="py-5">
|
|
3514
|
+
<p>Return value:</p>
|
|
3515
|
+
<code>number</code>
|
|
3516
|
+
</div>
|
|
3517
|
+
<!--end::Return value-->
|
|
3518
|
+
<!--begin::Code-->
|
|
3519
|
+
<div class="py-5">
|
|
3520
|
+
<!--begin::Highlight-->
|
|
3521
|
+
<div class="highlight">
|
|
3522
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3523
|
+
<div class="highlight-code">
|
|
3524
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 5 --}}
|
|
3525
|
+
{{floor 5.6}}</code></pre>
|
|
3526
|
+
</div>
|
|
3527
|
+
</div>
|
|
3528
|
+
<!--end::Highlight-->
|
|
3529
|
+
</div>
|
|
3530
|
+
<!--end::Code-->
|
|
3531
|
+
</td>
|
|
3532
|
+
</tr>
|
|
3533
|
+
<tr>
|
|
3534
|
+
<td class="w-250px"><code>abs()</code></td>
|
|
3535
|
+
<td>
|
|
3536
|
+
Returns an absolute value.
|
|
3537
|
+
<!--begin::Parameters-->
|
|
3538
|
+
<div class="py-5">
|
|
3539
|
+
<p>Parameters:</p>
|
|
3540
|
+
<ul>
|
|
3541
|
+
<li><code>val: number|string</code> Number to perform absolute value operation on.</li>
|
|
3542
|
+
</ul>
|
|
3543
|
+
</div>
|
|
3544
|
+
<!--end::Parameters-->
|
|
3545
|
+
<!--begin::Return value-->
|
|
3546
|
+
<div class="py-5">
|
|
3547
|
+
<p>Return value:</p>
|
|
3548
|
+
<code>number</code>
|
|
3549
|
+
</div>
|
|
3550
|
+
<!--end::Return value-->
|
|
3551
|
+
<!--begin::Code-->
|
|
3552
|
+
<div class="py-5">
|
|
3553
|
+
<!--begin::Highlight-->
|
|
3554
|
+
<div class="highlight">
|
|
3555
|
+
<button class="highlight-copy btn" data-bs-toggle="tooltip" title="Copy code">copy</button>
|
|
3556
|
+
<div class="highlight-code">
|
|
3557
|
+
<pre class="language-javascript"><code class="language-javascript">{{!-- results in: 5.6 --}}
|
|
3558
|
+
{{abs -5.6}}</code></pre>
|
|
3559
|
+
</div>
|
|
3560
|
+
</div>
|
|
3561
|
+
<!--end::Highlight-->
|
|
3562
|
+
</div>
|
|
3563
|
+
<!--end::Code-->
|
|
3564
|
+
</td>
|
|
3565
|
+
</tr>
|
|
3566
|
+
</tbody>
|
|
3567
|
+
<!--end::Body-->
|
|
3568
|
+
</table>
|
|
3569
|
+
<!--end::Table-->
|
|
3570
|
+
</div>
|
|
3571
|
+
<!--end::Table wrapper-->
|
|
3572
|
+
</div>
|
|
3573
|
+
<!--end::Table-->
|
|
3296
3574
|
</div>
|
|
3297
3575
|
<!--end::Section-->
|
|
3298
3576
|
</div>
|
package/package.json
CHANGED
|
@@ -4,4 +4,5 @@ import * as string from '~/handlebars_helpers/string';
|
|
|
4
4
|
import * as comparison from '~/handlebars_helpers/comparison';
|
|
5
5
|
import * as date from '~/handlebars_helpers/date';
|
|
6
6
|
import * as number from '~/handlebars_helpers/number';
|
|
7
|
-
|
|
7
|
+
import * as math from '~/handlebars_helpers/math';
|
|
8
|
+
export { html, object, string, comparison, date, number, math, };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the sum of two numbers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* {{!-- results in: 3 --}}
|
|
6
|
+
* {{add 1 2}}
|
|
7
|
+
*
|
|
8
|
+
* @param {number|string} val1 The first number.
|
|
9
|
+
* @param {number|string} val2 The second number.
|
|
10
|
+
* @returns {number}
|
|
11
|
+
*/
|
|
12
|
+
export declare function add(val1: number | string, val2: number | string): number;
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the difference of the given values.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* {{!-- results in: 3 --}}
|
|
18
|
+
* {{sub 5 2}}
|
|
19
|
+
*
|
|
20
|
+
* @param {number|string} val1 The first number.
|
|
21
|
+
* @param {number|string} val2 The second number.
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
export declare function sub(val1: number | string, val2: number | string): number;
|
|
25
|
+
/**
|
|
26
|
+
* Calculate the multiplication of the given values.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* {{!-- results in: 10 --}}
|
|
30
|
+
* {{multiply 5 2}}
|
|
31
|
+
*
|
|
32
|
+
* @param {number|string} val1 The first number.
|
|
33
|
+
* @param {number|string} val2 The second number.
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
export declare function multiply(val1: number | string, val2: number | string): number;
|
|
37
|
+
/**
|
|
38
|
+
* Compute the division of the given values.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* {{!-- results in: 5 --}}
|
|
42
|
+
* {{divide 10 2}}
|
|
43
|
+
*
|
|
44
|
+
* @param {number|string} val1 The first number.
|
|
45
|
+
* @param {number|string} val2 The second number.
|
|
46
|
+
* @returns {number}
|
|
47
|
+
*/
|
|
48
|
+
export declare function divide(val1: number | string, val2: number | string): number;
|
|
49
|
+
/**
|
|
50
|
+
* Round up the value.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* {{!-- results in: 6 --}}
|
|
54
|
+
* {{ceil 5.6}}
|
|
55
|
+
*
|
|
56
|
+
* @param {number|string} val Number to be rounded to nearest greater integer.
|
|
57
|
+
* @returns {number}
|
|
58
|
+
*/
|
|
59
|
+
export declare function ceil(val: number | string): number;
|
|
60
|
+
/**
|
|
61
|
+
* Rounds down a number.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* {{!-- results in: 5 --}}
|
|
65
|
+
* {{floor 5.6}}
|
|
66
|
+
*
|
|
67
|
+
* @param {number|string} val Number to be rounded to nearest lower integer.
|
|
68
|
+
* @returns {number}
|
|
69
|
+
*/
|
|
70
|
+
export declare function floor(val: number | string): number;
|
|
71
|
+
/**
|
|
72
|
+
* Returns an absolute value.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* {{!-- results in: 5.6 --}}
|
|
76
|
+
* {{abs -5.6}}
|
|
77
|
+
*
|
|
78
|
+
* @param {number} val Number to perform absolute value operation on.
|
|
79
|
+
* @returns {number}
|
|
80
|
+
*/
|
|
81
|
+
export declare function abs(val: number | string): number;
|
|
@@ -38,7 +38,7 @@ export default interface {
|
|
|
38
38
|
* res.locals.message = 'Hello World';
|
|
39
39
|
* }
|
|
40
40
|
*
|
|
41
|
-
* @type {(res: express.Response) => void}
|
|
41
|
+
* @type {(res: express.Response) => Promise<void>|void}
|
|
42
42
|
*/
|
|
43
|
-
beforeRender?: (req: express.Request, res: express.Response) => void;
|
|
43
|
+
beforeRender?: (req: express.Request, res: express.Response) => Promise<void> | void;
|
|
44
44
|
}
|