@jaredwray/fumanchu 1.2.1 → 1.4.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 +117 -126
- package/index.d.ts +5 -3
- package/index.mjs +8 -3
- package/lib/markdown.js +46 -2
- package/lib/md.js +119 -0
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -23,8 +23,6 @@ Handlebars + Helpers Together
|
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
npm install @jaredwray/fumanchu --save
|
|
26
|
-
// or
|
|
27
|
-
yarn add @jaredwray/fumanchu
|
|
28
26
|
```
|
|
29
27
|
|
|
30
28
|
```javascript
|
|
@@ -238,8 +236,6 @@ Visit the: [code](lib/logging.js) | [unit tests](test/logging.js) | [issues](htt
|
|
|
238
236
|
|
|
239
237
|
### [markdown helpers](#markdown)
|
|
240
238
|
|
|
241
|
-
Visit the: [code](lib/markdown.js) | [unit tests](test/markdown.js) | [issues](https://github.com/jonathas/handlebars-helpers/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+markdown+helpers))
|
|
242
|
-
|
|
243
239
|
* **[markdown](#markdown)** ([code](lib/markdown.js#Lundefined) | [tests](test/markdown.js#L10))
|
|
244
240
|
* **[md](#md)** ([code](lib/markdown.js#L55) | [tests](test/markdown.js#L18))
|
|
245
241
|
|
|
@@ -406,7 +402,7 @@ Returns all of the items in an array after the specified index. Opposite of [bef
|
|
|
406
402
|
|
|
407
403
|
**Example**
|
|
408
404
|
|
|
409
|
-
```
|
|
405
|
+
```html
|
|
410
406
|
<!-- array: ['a', 'b', 'c'] -->
|
|
411
407
|
{{after array 1}}
|
|
412
408
|
<!-- results in: '["c"]' -->
|
|
@@ -423,7 +419,7 @@ Cast the given `value` to an array.
|
|
|
423
419
|
|
|
424
420
|
**Example**
|
|
425
421
|
|
|
426
|
-
```
|
|
422
|
+
```html
|
|
427
423
|
{{arrayify "foo"}}
|
|
428
424
|
<!-- results in: [ "foo" ] -->
|
|
429
425
|
```
|
|
@@ -440,7 +436,7 @@ Return all of the items in the collection before the specified count. Opposite o
|
|
|
440
436
|
|
|
441
437
|
**Example**
|
|
442
438
|
|
|
443
|
-
```
|
|
439
|
+
```html
|
|
444
440
|
<!-- array: ['a', 'b', 'c'] -->
|
|
445
441
|
{{before array 2}}
|
|
446
442
|
<!-- results in: '["a", "b"]' -->
|
|
@@ -456,7 +452,7 @@ Return all of the items in the collection before the specified count. Opposite o
|
|
|
456
452
|
|
|
457
453
|
**Example**
|
|
458
454
|
|
|
459
|
-
```
|
|
455
|
+
```html
|
|
460
456
|
<!-- array: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] -->
|
|
461
457
|
{{#eachIndex array}}
|
|
462
458
|
{{item}} is {{index}}
|
|
@@ -476,7 +472,7 @@ Block helper that filters the given array and renders the block for values that
|
|
|
476
472
|
|
|
477
473
|
**Example**
|
|
478
474
|
|
|
479
|
-
```
|
|
475
|
+
```html
|
|
480
476
|
<!-- array: ['a', 'b', 'c'] -->
|
|
481
477
|
{{#filter array "foo"}}AAA{{else}}BBB{{/filter}}
|
|
482
478
|
<!-- results in: 'BBB' -->
|
|
@@ -494,7 +490,7 @@ Returns the first item, or first `n` items of an array.
|
|
|
494
490
|
|
|
495
491
|
**Example**
|
|
496
492
|
|
|
497
|
-
```
|
|
493
|
+
```html
|
|
498
494
|
{{first "['a', 'b', 'c', 'd', 'e']" 2}}
|
|
499
495
|
<!-- results in: '["a", "b"]' -->
|
|
500
496
|
```
|
|
@@ -517,7 +513,7 @@ private variables may be defined as hash arguments.
|
|
|
517
513
|
|
|
518
514
|
**Example**
|
|
519
515
|
|
|
520
|
-
```
|
|
516
|
+
```html
|
|
521
517
|
<!-- accounts = [
|
|
522
518
|
{'name': 'John', 'email': 'john@example.com'},
|
|
523
519
|
{'name': 'Malcolm', 'email': 'malcolm@example.com'},
|
|
@@ -544,7 +540,7 @@ Block helper that renders the block if an array has the given `value`. Optionall
|
|
|
544
540
|
|
|
545
541
|
**Example**
|
|
546
542
|
|
|
547
|
-
```
|
|
543
|
+
```html
|
|
548
544
|
<!-- array: ['a', 'b', 'c'] -->
|
|
549
545
|
{{#inArray array "d"}}
|
|
550
546
|
foo
|
|
@@ -565,7 +561,7 @@ Returns true if `value` is an es5 array.
|
|
|
565
561
|
|
|
566
562
|
**Example**
|
|
567
563
|
|
|
568
|
-
```
|
|
564
|
+
```html
|
|
569
565
|
{{isArray "abc"}}
|
|
570
566
|
<!-- results in: false -->
|
|
571
567
|
|
|
@@ -586,7 +582,7 @@ Returns the item from `array` at index `idx`.
|
|
|
586
582
|
|
|
587
583
|
**Example**
|
|
588
584
|
|
|
589
|
-
```
|
|
585
|
+
```html
|
|
590
586
|
<!-- array: ['a', 'b', 'c'] -->
|
|
591
587
|
{{itemAt array 1}}
|
|
592
588
|
<!-- results in: 'b' -->
|
|
@@ -604,7 +600,7 @@ Join all elements of array into a string, optionally using a given separator.
|
|
|
604
600
|
|
|
605
601
|
**Example**
|
|
606
602
|
|
|
607
|
-
```
|
|
603
|
+
```html
|
|
608
604
|
<!-- array: ['a', 'b', 'c'] -->
|
|
609
605
|
{{join array}}
|
|
610
606
|
<!-- results in: 'a, b, c' -->
|
|
@@ -612,7 +608,6 @@ Join all elements of array into a string, optionally using a given separator.
|
|
|
612
608
|
{{join array '-'}}
|
|
613
609
|
<!-- results in: 'a-b-c' -->
|
|
614
610
|
```
|
|
615
|
-
|
|
616
611
|
### [{{equalsLength}}](lib/array.js#L313)
|
|
617
612
|
|
|
618
613
|
Returns true if the the length of the given `value` is equal
|
|
@@ -637,7 +632,7 @@ Returns the last item, or last `n` items of an array or string. Opposite of [fir
|
|
|
637
632
|
|
|
638
633
|
**Example**
|
|
639
634
|
|
|
640
|
-
```
|
|
635
|
+
```html
|
|
641
636
|
<!-- var value = ['a', 'b', 'c', 'd', 'e'] -->
|
|
642
637
|
|
|
643
638
|
{{last value}}
|
|
@@ -661,7 +656,7 @@ Returns the length of the given string or array.
|
|
|
661
656
|
|
|
662
657
|
**Example**
|
|
663
658
|
|
|
664
|
-
```
|
|
659
|
+
```html
|
|
665
660
|
{{length '["a", "b", "c"]'}}
|
|
666
661
|
<!-- results in: 3 -->
|
|
667
662
|
|
|
@@ -690,7 +685,7 @@ Returns a new array, created by calling `function` on each element of the given
|
|
|
690
685
|
|
|
691
686
|
**Example**
|
|
692
687
|
|
|
693
|
-
```
|
|
688
|
+
```html
|
|
694
689
|
<!-- array: ['a', 'b', 'c'], and "double" is a
|
|
695
690
|
fictitious function that duplicates letters -->
|
|
696
691
|
{{map array double}}
|
|
@@ -709,7 +704,7 @@ Map over the given object or array or objects and create an array of values from
|
|
|
709
704
|
|
|
710
705
|
**Example**
|
|
711
706
|
|
|
712
|
-
```
|
|
707
|
+
```html
|
|
713
708
|
// {{pluck items "data.title"}}
|
|
714
709
|
<!-- results in: '["aa", "bb", "cc"]' -->
|
|
715
710
|
```
|
|
@@ -725,7 +720,7 @@ Reverse the elements in an array, or the characters in a string.
|
|
|
725
720
|
|
|
726
721
|
**Example**
|
|
727
722
|
|
|
728
|
-
```
|
|
723
|
+
```html
|
|
729
724
|
<!-- value: 'abcd' -->
|
|
730
725
|
{{reverse value}}
|
|
731
726
|
<!-- results in: 'dcba' -->
|
|
@@ -747,7 +742,7 @@ Block helper that returns the block if the callback returns true for some value
|
|
|
747
742
|
|
|
748
743
|
**Example**
|
|
749
744
|
|
|
750
|
-
```
|
|
745
|
+
```html
|
|
751
746
|
<!-- array: [1, 'b', 3] -->
|
|
752
747
|
{{#some array isString}}
|
|
753
748
|
Render me if the array has a string.
|
|
@@ -768,7 +763,7 @@ Sort the given `array`. If an array of objects is passed, you may optionally pas
|
|
|
768
763
|
|
|
769
764
|
**Example**
|
|
770
765
|
|
|
771
|
-
```
|
|
766
|
+
```html
|
|
772
767
|
<!-- array: ['b', 'a', 'c'] -->
|
|
773
768
|
{{sort array}}
|
|
774
769
|
<!-- results in: '["a", "b", "c"]' -->
|
|
@@ -785,7 +780,7 @@ Sort an `array`. If an array of objects is passed, you may optionally pass a `ke
|
|
|
785
780
|
|
|
786
781
|
**Example**
|
|
787
782
|
|
|
788
|
-
```
|
|
783
|
+
```html
|
|
789
784
|
<!-- array: [{a: 'zzz'}, {a: 'aaa'}] -->
|
|
790
785
|
{{sortBy array "a"}}
|
|
791
786
|
<!-- results in: '[{"a":"aaa"}, {"a":"zzz"}]' -->
|
|
@@ -804,7 +799,7 @@ Use the items in the array _after_ the specified index as context inside a block
|
|
|
804
799
|
|
|
805
800
|
**Example**
|
|
806
801
|
|
|
807
|
-
```
|
|
802
|
+
```html
|
|
808
803
|
<!-- array: ['a', 'b', 'c', 'd', 'e'] -->
|
|
809
804
|
{{#withAfter array 3}}
|
|
810
805
|
{{this}}
|
|
@@ -825,7 +820,7 @@ Use the items in the array _before_ the specified index as context inside a bloc
|
|
|
825
820
|
|
|
826
821
|
**Example**
|
|
827
822
|
|
|
828
|
-
```
|
|
823
|
+
```html
|
|
829
824
|
<!-- array: ['a', 'b', 'c', 'd', 'e'] -->
|
|
830
825
|
{{#withBefore array 3}}
|
|
831
826
|
{{this}}
|
|
@@ -846,7 +841,7 @@ Use the first item in a collection inside a handlebars block expression. Opposit
|
|
|
846
841
|
|
|
847
842
|
**Example**
|
|
848
843
|
|
|
849
|
-
```
|
|
844
|
+
```html
|
|
850
845
|
<!-- array: ['a', 'b', 'c'] -->
|
|
851
846
|
{{#withFirst array}}
|
|
852
847
|
{{this}}
|
|
@@ -867,7 +862,7 @@ Block helper that groups array elements by given group `size`.
|
|
|
867
862
|
|
|
868
863
|
**Example**
|
|
869
864
|
|
|
870
|
-
```
|
|
865
|
+
```html
|
|
871
866
|
<!-- array: ['a','b','c','d','e','f','g','h'] -->
|
|
872
867
|
{{#withGroup array 4}}
|
|
873
868
|
{{#each this}}
|
|
@@ -893,7 +888,7 @@ Use the last item or `n` items in an array as context inside a block. Opposite o
|
|
|
893
888
|
|
|
894
889
|
**Example**
|
|
895
890
|
|
|
896
|
-
```
|
|
891
|
+
```html
|
|
897
892
|
<!-- array: ['a', 'b', 'c'] -->
|
|
898
893
|
{{#withLast array}}
|
|
899
894
|
{{this}}
|
|
@@ -914,7 +909,7 @@ Block helper that sorts a collection and exposes the sorted collection as contex
|
|
|
914
909
|
|
|
915
910
|
**Example**
|
|
916
911
|
|
|
917
|
-
```
|
|
912
|
+
```html
|
|
918
913
|
<!-- array: ['b', 'a', 'c'] -->
|
|
919
914
|
{{#withSort array}}{{this}}{{/withSort}}
|
|
920
915
|
<!-- results in: 'abc' -->
|
|
@@ -932,14 +927,12 @@ Block helper that return an array with all duplicate values removed. Best used a
|
|
|
932
927
|
|
|
933
928
|
**Example**
|
|
934
929
|
|
|
935
|
-
```
|
|
930
|
+
```html
|
|
936
931
|
<!-- array: ['a', 'a', 'c', 'b', 'e', 'e'] -->
|
|
937
932
|
{{#each (unique array)}}{{.}}{{/each}}
|
|
938
933
|
<!-- results in: 'acbe' -->
|
|
939
934
|
```
|
|
940
935
|
|
|
941
|
-
## code
|
|
942
|
-
|
|
943
936
|
### [{{embed}}](lib/code.js#L23)
|
|
944
937
|
|
|
945
938
|
Embed code from an external file as preformatted text.
|
|
@@ -952,7 +945,7 @@ Embed code from an external file as preformatted text.
|
|
|
952
945
|
|
|
953
946
|
**Example**
|
|
954
947
|
|
|
955
|
-
```
|
|
948
|
+
```html
|
|
956
949
|
{{embed 'path/to/file.js'}}
|
|
957
950
|
<!-- optionally specify the language to use -->
|
|
958
951
|
{{embed 'path/to/file.hbs' 'html')}}
|
|
@@ -969,7 +962,7 @@ Embed a GitHub Gist using only the id of the Gist
|
|
|
969
962
|
|
|
970
963
|
**Example**
|
|
971
964
|
|
|
972
|
-
```
|
|
965
|
+
```html
|
|
973
966
|
{{gist "12345"}}
|
|
974
967
|
```
|
|
975
968
|
|
|
@@ -984,7 +977,7 @@ Generate the HTML for a jsFiddle link with the given `params`
|
|
|
984
977
|
|
|
985
978
|
**Example**
|
|
986
979
|
|
|
987
|
-
```
|
|
980
|
+
```html
|
|
988
981
|
{{jsfiddle id="0dfk10ks" tabs="true"}}
|
|
989
982
|
```
|
|
990
983
|
|
|
@@ -1002,7 +995,7 @@ Inline, subexpression, or block helper that returns true (or the block) if the g
|
|
|
1002
995
|
|
|
1003
996
|
**Example**
|
|
1004
997
|
|
|
1005
|
-
```
|
|
998
|
+
```html
|
|
1006
999
|
<!-- array: [] -->
|
|
1007
1000
|
{{#isEmpty array}}AAA{{else}}BBB{{/isEmpty}}
|
|
1008
1001
|
<!-- results in: 'AAA' -->
|
|
@@ -1040,7 +1033,7 @@ Helper that renders the block if **both** of the given values are truthy. If an
|
|
|
1040
1033
|
|
|
1041
1034
|
**Example**
|
|
1042
1035
|
|
|
1043
|
-
```
|
|
1036
|
+
```html
|
|
1044
1037
|
<!-- {great: true, magnificent: true} -->
|
|
1045
1038
|
{{#and great magnificent}}A{{else}}B{{/and}}
|
|
1046
1039
|
<!-- results in: 'A' -->
|
|
@@ -1074,7 +1067,7 @@ Block helper that renders the block if `collection` has the given `value`, using
|
|
|
1074
1067
|
|
|
1075
1068
|
**Example**
|
|
1076
1069
|
|
|
1077
|
-
```
|
|
1070
|
+
```html
|
|
1078
1071
|
<!-- array = ['a', 'b', 'c'] -->
|
|
1079
1072
|
{{#contains array "d"}}
|
|
1080
1073
|
This will not be rendered.
|
|
@@ -1083,9 +1076,9 @@ Block helper that renders the block if `collection` has the given `value`, using
|
|
|
1083
1076
|
{{/contains}}
|
|
1084
1077
|
```
|
|
1085
1078
|
|
|
1086
|
-
### [{{default}}](lib/comparison.js#L143)
|
|
1079
|
+
### [`{{default}}`](lib/comparison.js#L143)
|
|
1087
1080
|
|
|
1088
|
-
Returns the first value that is not undefined, otherwise the
|
|
1081
|
+
Returns the first value that is not undefined, otherwise the `default` value is returned.
|
|
1089
1082
|
|
|
1090
1083
|
**Params**
|
|
1091
1084
|
|
|
@@ -1185,7 +1178,7 @@ Return true if the given value is an even number.
|
|
|
1185
1178
|
|
|
1186
1179
|
**Example**
|
|
1187
1180
|
|
|
1188
|
-
```
|
|
1181
|
+
```html
|
|
1189
1182
|
{{#ifEven value}}
|
|
1190
1183
|
render A
|
|
1191
1184
|
{{else}}
|
|
@@ -1218,7 +1211,7 @@ Block helper that renders a block if `value` is **an odd number**. If an inverse
|
|
|
1218
1211
|
|
|
1219
1212
|
**Example**
|
|
1220
1213
|
|
|
1221
|
-
```
|
|
1214
|
+
```html
|
|
1222
1215
|
{{#ifOdd value}}
|
|
1223
1216
|
render A
|
|
1224
1217
|
{{else}}
|
|
@@ -1226,7 +1219,7 @@ Block helper that renders a block if `value` is **an odd number**. If an inverse
|
|
|
1226
1219
|
{{/ifOdd}}
|
|
1227
1220
|
```
|
|
1228
1221
|
|
|
1229
|
-
### [{{is}}](lib/comparison.js#L367)
|
|
1222
|
+
### [`{{is}}`](lib/comparison.js#L367)
|
|
1230
1223
|
|
|
1231
1224
|
Block helper that renders a block if `a` is **equal to** `b`.
|
|
1232
1225
|
If an inverse block is specified it will be rendered when falsy.
|
|
@@ -1239,7 +1232,7 @@ Similar to [eq](#eq) but does not do strict equality.
|
|
|
1239
1232
|
* `options` **{Object}**: Handlebars provided options object
|
|
1240
1233
|
* `returns` **{String}**
|
|
1241
1234
|
|
|
1242
|
-
### [{{isnt}}](lib/comparison.js#L389)
|
|
1235
|
+
### [`{{isnt}}`](lib/comparison.js#L389)
|
|
1243
1236
|
|
|
1244
1237
|
Block helper that renders a block if `a` is **not equal to** `b`.
|
|
1245
1238
|
If an inverse block is specified it will be rendered when falsy.
|
|
@@ -1253,7 +1246,7 @@ comparisons.
|
|
|
1253
1246
|
* `options` **{Object}**: Handlebars provided options object
|
|
1254
1247
|
* `returns` **{String}**
|
|
1255
1248
|
|
|
1256
|
-
### [{{lt}}](lib/comparison.js#L411)
|
|
1249
|
+
### [`{{lt}}`](lib/comparison.js#L411)
|
|
1257
1250
|
|
|
1258
1251
|
Block helper that renders a block if `a` is **less than** `b`.
|
|
1259
1252
|
|
|
@@ -1267,7 +1260,7 @@ second value.
|
|
|
1267
1260
|
* `options` **{Object}**: Handlebars provided options object
|
|
1268
1261
|
* `returns` **{String}**: Block, or inverse block if specified and falsey.
|
|
1269
1262
|
|
|
1270
|
-
### [{{lte}}](lib/comparison.js#L435)
|
|
1263
|
+
### [`{{lte}}`](lib/comparison.js#L435)
|
|
1271
1264
|
|
|
1272
1265
|
Block helper that renders a block if `a` is **less than or equal to** `b`.
|
|
1273
1266
|
|
|
@@ -1282,7 +1275,7 @@ second value.
|
|
|
1282
1275
|
* `options` **{Object}**: Handlebars provided options object
|
|
1283
1276
|
* `returns` **{String}**: Block, or inverse block if specified and falsey.
|
|
1284
1277
|
|
|
1285
|
-
### [{{neither}}](lib/comparison.js#L456)
|
|
1278
|
+
### [`{{neither}}`](lib/comparison.js#L456)
|
|
1286
1279
|
|
|
1287
1280
|
Block helper that renders a block if **neither of** the given values
|
|
1288
1281
|
are truthy. If an inverse block is specified it will be rendered
|
|
@@ -1295,7 +1288,7 @@ when falsy.
|
|
|
1295
1288
|
* `options` **{}**: Handlebars options object
|
|
1296
1289
|
* `returns` **{String}**: Block, or inverse block if specified and falsey.
|
|
1297
1290
|
|
|
1298
|
-
### [{{not}}](lib/comparison.js#L470)
|
|
1291
|
+
### [`{{not}}`](lib/comparison.js#L470)
|
|
1299
1292
|
|
|
1300
1293
|
Returns true if `val` is falsey. Works as a block or inline helper.
|
|
1301
1294
|
|
|
@@ -1305,19 +1298,19 @@ Returns true if `val` is falsey. Works as a block or inline helper.
|
|
|
1305
1298
|
* `options` **{Object}**: Handlebars provided options object
|
|
1306
1299
|
* `returns` **{String}**
|
|
1307
1300
|
|
|
1308
|
-
### [{{or}}](lib/comparison.js#L492)
|
|
1301
|
+
### [`{{or}}`](lib/comparison.js#L492)
|
|
1309
1302
|
|
|
1310
1303
|
Block helper that renders a block if **any of** the given values is truthy. If an inverse block is specified it will be rendered when falsy.
|
|
1311
1304
|
|
|
1312
1305
|
**Params**
|
|
1313
1306
|
|
|
1314
|
-
* `
|
|
1307
|
+
* `args` **{any}**: Variable number of arguments
|
|
1315
1308
|
* `options` **{Object}**: Handlebars options object
|
|
1316
1309
|
* `returns` **{String}**: Block, or inverse block if specified and falsey.
|
|
1317
1310
|
|
|
1318
1311
|
**Example**
|
|
1319
1312
|
|
|
1320
|
-
```
|
|
1313
|
+
```html
|
|
1321
1314
|
{{#or a b c}}
|
|
1322
1315
|
If any value is true this will be rendered.
|
|
1323
1316
|
{{/or}}
|
|
@@ -1391,14 +1384,14 @@ Get the current year.
|
|
|
1391
1384
|
|
|
1392
1385
|
**Example**
|
|
1393
1386
|
|
|
1394
|
-
```
|
|
1387
|
+
```html
|
|
1395
1388
|
{{year}}
|
|
1396
1389
|
<!-- 2017 -->
|
|
1397
1390
|
```
|
|
1398
1391
|
|
|
1399
1392
|
### [{{moment}}](lib/date.js#L24)
|
|
1400
1393
|
|
|
1401
|
-
Use [moment](http://momentjs.com) as a helper. See [helper-date](https://github.com/
|
|
1394
|
+
Use [moment](http://momentjs.com) as a helper. See [helper-date](https://github.com/helpers/helper-date) for more details.
|
|
1402
1395
|
|
|
1403
1396
|
## fs
|
|
1404
1397
|
|
|
@@ -1413,7 +1406,7 @@ Read a file from the file system. This is useful in composing "include"-style he
|
|
|
1413
1406
|
|
|
1414
1407
|
**Example**
|
|
1415
1408
|
|
|
1416
|
-
```
|
|
1409
|
+
```html
|
|
1417
1410
|
{{read "a/b/c.js"}}
|
|
1418
1411
|
{{someHelper (read "a/b/c.md")}}
|
|
1419
1412
|
```
|
|
@@ -1441,7 +1434,7 @@ Stringify attributes on the options `hash`.
|
|
|
1441
1434
|
|
|
1442
1435
|
**Example**
|
|
1443
1436
|
|
|
1444
|
-
```
|
|
1437
|
+
```html
|
|
1445
1438
|
<!-- value = 'bar' -->
|
|
1446
1439
|
<div{{attr foo=value}}></div>
|
|
1447
1440
|
<!-- results in: <div foo="bar"></div>
|
|
@@ -1458,7 +1451,7 @@ Add an array of `<link>` tags. Automatically resolves relative paths to `options
|
|
|
1458
1451
|
|
|
1459
1452
|
**Example**
|
|
1460
1453
|
|
|
1461
|
-
```
|
|
1454
|
+
```html
|
|
1462
1455
|
<!-- {stylesheets: ['foo.css', 'bar.css']} -->
|
|
1463
1456
|
{{css stylesheets}}
|
|
1464
1457
|
|
|
@@ -1478,7 +1471,7 @@ Generate one or more `<script></script>` tags with paths/urls to javascript or c
|
|
|
1478
1471
|
|
|
1479
1472
|
**Example**
|
|
1480
1473
|
|
|
1481
|
-
```
|
|
1474
|
+
```html
|
|
1482
1475
|
{{js scripts}}
|
|
1483
1476
|
```
|
|
1484
1477
|
|
|
@@ -1493,7 +1486,7 @@ Strip HTML tags from a string, so that only the text nodes are preserved.
|
|
|
1493
1486
|
|
|
1494
1487
|
**Example**
|
|
1495
1488
|
|
|
1496
|
-
```
|
|
1489
|
+
```html
|
|
1497
1490
|
{{sanitize "<span>foo</span>"}}
|
|
1498
1491
|
<!-- results in: 'foo' -->
|
|
1499
1492
|
```
|
|
@@ -1560,7 +1553,7 @@ Returns either the `singular` or `plural` inflection of a word based on the give
|
|
|
1560
1553
|
|
|
1561
1554
|
**Example**
|
|
1562
1555
|
|
|
1563
|
-
```
|
|
1556
|
+
```html
|
|
1564
1557
|
{{inflect 0 "string" "strings"}}
|
|
1565
1558
|
<!-- "strings" -->
|
|
1566
1559
|
{{inflect 1 "string" "strings"}}
|
|
@@ -1584,7 +1577,7 @@ Returns an ordinalized number as a string.
|
|
|
1584
1577
|
|
|
1585
1578
|
**Example**
|
|
1586
1579
|
|
|
1587
|
-
```
|
|
1580
|
+
```html
|
|
1588
1581
|
{{ordinalize 1}}
|
|
1589
1582
|
<!-- '1st' -->
|
|
1590
1583
|
{{ordinalize 21}}
|
|
@@ -1613,7 +1606,7 @@ Block helper that converts a string of inline markdown to HTML.
|
|
|
1613
1606
|
|
|
1614
1607
|
**Example**
|
|
1615
1608
|
|
|
1616
|
-
```
|
|
1609
|
+
```html
|
|
1617
1610
|
{{#markdown}}
|
|
1618
1611
|
# Foo
|
|
1619
1612
|
{{/markdown}}
|
|
@@ -1632,7 +1625,7 @@ Read a markdown file from the file system and inject its contents after converti
|
|
|
1632
1625
|
|
|
1633
1626
|
**Example**
|
|
1634
1627
|
|
|
1635
|
-
```
|
|
1628
|
+
```html
|
|
1636
1629
|
{{md "foo/bar.md"}}
|
|
1637
1630
|
```
|
|
1638
1631
|
|
|
@@ -1652,7 +1645,7 @@ Returns an array of strings that match the given glob pattern(s). Options may be
|
|
|
1652
1645
|
|
|
1653
1646
|
**Example**
|
|
1654
1647
|
|
|
1655
|
-
```
|
|
1648
|
+
```html
|
|
1656
1649
|
{{match (readdir "foo") "*.js"}}
|
|
1657
1650
|
{{match (readdir "foo") (toRegex "\\.js$")}}
|
|
1658
1651
|
```
|
|
@@ -1670,7 +1663,7 @@ Returns true if a filepath contains the given pattern. Options may be passed on
|
|
|
1670
1663
|
|
|
1671
1664
|
**Example**
|
|
1672
1665
|
|
|
1673
|
-
```
|
|
1666
|
+
```html
|
|
1674
1667
|
{{isMatch "foo.md" "*.md"}}
|
|
1675
1668
|
<!-- results in: true -->
|
|
1676
1669
|
```
|
|
@@ -1707,7 +1700,7 @@ Returns the average of all numbers in the given array.
|
|
|
1707
1700
|
|
|
1708
1701
|
**Example**
|
|
1709
1702
|
|
|
1710
|
-
```
|
|
1703
|
+
```html
|
|
1711
1704
|
{{avg "[1, 2, 3, 4, 5]"}}
|
|
1712
1705
|
<!-- results in: '3' -->
|
|
1713
1706
|
```
|
|
@@ -1826,7 +1819,7 @@ Returns the sum of all numbers in the given array.
|
|
|
1826
1819
|
|
|
1827
1820
|
**Example**
|
|
1828
1821
|
|
|
1829
|
-
```
|
|
1822
|
+
```html
|
|
1830
1823
|
{{sum "[1, 2, 3, 4, 5]"}}
|
|
1831
1824
|
<!-- results in: '15' -->
|
|
1832
1825
|
```
|
|
@@ -1854,7 +1847,7 @@ Return the given value of `prop` from `this.options`.
|
|
|
1854
1847
|
|
|
1855
1848
|
**Example**
|
|
1856
1849
|
|
|
1857
|
-
```
|
|
1850
|
+
```html
|
|
1858
1851
|
<!-- context = {options: {a: {b: {c: 'ddd'}}}} -->
|
|
1859
1852
|
{{option "a.b.c"}}
|
|
1860
1853
|
<!-- results => `ddd` -->
|
|
@@ -1880,7 +1873,7 @@ Get the native type of the given `value`
|
|
|
1880
1873
|
|
|
1881
1874
|
**Example**
|
|
1882
1875
|
|
|
1883
|
-
```
|
|
1876
|
+
```html
|
|
1884
1877
|
{{typeOf 1}}
|
|
1885
1878
|
//=> 'number'
|
|
1886
1879
|
{{typeOf "1"}}
|
|
@@ -1957,7 +1950,7 @@ Returns a string representing the given number in exponential notation.
|
|
|
1957
1950
|
|
|
1958
1951
|
**Example**
|
|
1959
1952
|
|
|
1960
|
-
```
|
|
1953
|
+
```html
|
|
1961
1954
|
{{toExponential number digits}};
|
|
1962
1955
|
```
|
|
1963
1956
|
|
|
@@ -1973,7 +1966,7 @@ Formats the given number using fixed-point notation.
|
|
|
1973
1966
|
|
|
1974
1967
|
**Example**
|
|
1975
1968
|
|
|
1976
|
-
```
|
|
1969
|
+
```html
|
|
1977
1970
|
{{toFixed "1.1234" 2}}
|
|
1978
1971
|
//=> '1.12'
|
|
1979
1972
|
```
|
|
@@ -2004,7 +1997,7 @@ Returns a string representing the `Number` object to the specified precision.
|
|
|
2004
1997
|
|
|
2005
1998
|
**Example**
|
|
2006
1999
|
|
|
2007
|
-
```
|
|
2000
|
+
```html
|
|
2008
2001
|
{{toPrecision "1.1234" 2}}
|
|
2009
2002
|
//=> '1.1'
|
|
2010
2003
|
```
|
|
@@ -2090,7 +2083,7 @@ Return true if `key` is an own, enumerable property of the given `context` objec
|
|
|
2090
2083
|
|
|
2091
2084
|
**Example**
|
|
2092
2085
|
|
|
2093
|
-
```
|
|
2086
|
+
```html
|
|
2094
2087
|
{{hasOwn context key}}
|
|
2095
2088
|
```
|
|
2096
2089
|
|
|
@@ -2105,7 +2098,7 @@ Return true if `value` is an object.
|
|
|
2105
2098
|
|
|
2106
2099
|
**Example**
|
|
2107
2100
|
|
|
2108
|
-
```
|
|
2101
|
+
```html
|
|
2109
2102
|
{{isObject "foo"}}
|
|
2110
2103
|
//=> false
|
|
2111
2104
|
```
|
|
@@ -2120,7 +2113,7 @@ Parses the given string using `JSON.parse`.
|
|
|
2120
2113
|
|
|
2121
2114
|
**Example**
|
|
2122
2115
|
|
|
2123
|
-
```
|
|
2116
|
+
```html
|
|
2124
2117
|
<!-- string: '{"foo": "bar"}' -->
|
|
2125
2118
|
{{JSONparse string}}
|
|
2126
2119
|
<!-- results in: { foo: 'bar' } -->
|
|
@@ -2137,7 +2130,7 @@ Stringify an object using `JSON.stringify`.
|
|
|
2137
2130
|
|
|
2138
2131
|
**Example**
|
|
2139
2132
|
|
|
2140
|
-
```
|
|
2133
|
+
```html
|
|
2141
2134
|
<!-- object: { foo: 'bar' } -->
|
|
2142
2135
|
{{JSONstringify object}}
|
|
2143
2136
|
<!-- results in: '{"foo": "bar"}' -->
|
|
@@ -2178,7 +2171,7 @@ Get the directory path segment from the given `filepath`.
|
|
|
2178
2171
|
|
|
2179
2172
|
**Example**
|
|
2180
2173
|
|
|
2181
|
-
```
|
|
2174
|
+
```html
|
|
2182
2175
|
{{absolute "docs/toc.md"}}
|
|
2183
2176
|
<!-- results in: 'docs' -->
|
|
2184
2177
|
```
|
|
@@ -2194,7 +2187,7 @@ Get the directory path segment from the given `filepath`.
|
|
|
2194
2187
|
|
|
2195
2188
|
**Example**
|
|
2196
2189
|
|
|
2197
|
-
```
|
|
2190
|
+
```html
|
|
2198
2191
|
{{dirname "docs/toc.md"}}
|
|
2199
2192
|
<!-- results in: 'docs' -->
|
|
2200
2193
|
```
|
|
@@ -2211,7 +2204,7 @@ Get the relative filepath from `a` to `b`.
|
|
|
2211
2204
|
|
|
2212
2205
|
**Example**
|
|
2213
2206
|
|
|
2214
|
-
```
|
|
2207
|
+
```html
|
|
2215
2208
|
{{relative a b}}
|
|
2216
2209
|
```
|
|
2217
2210
|
|
|
@@ -2226,7 +2219,7 @@ Get the file extension from the given `filepath`.
|
|
|
2226
2219
|
|
|
2227
2220
|
**Example**
|
|
2228
2221
|
|
|
2229
|
-
```
|
|
2222
|
+
```html
|
|
2230
2223
|
{{basename "docs/toc.md"}}
|
|
2231
2224
|
<!-- results in: 'toc.md' -->
|
|
2232
2225
|
```
|
|
@@ -2242,7 +2235,7 @@ Get the "stem" from the given `filepath`.
|
|
|
2242
2235
|
|
|
2243
2236
|
**Example**
|
|
2244
2237
|
|
|
2245
|
-
```
|
|
2238
|
+
```html
|
|
2246
2239
|
{{stem "docs/toc.md"}}
|
|
2247
2240
|
<!-- results in: 'toc' -->
|
|
2248
2241
|
```
|
|
@@ -2258,7 +2251,7 @@ Get the file extension from the given `filepath`.
|
|
|
2258
2251
|
|
|
2259
2252
|
**Example**
|
|
2260
2253
|
|
|
2261
|
-
```
|
|
2254
|
+
```html
|
|
2262
2255
|
{{extname "docs/toc.md"}}
|
|
2263
2256
|
<!-- results in: '.md' -->
|
|
2264
2257
|
```
|
|
@@ -2274,7 +2267,7 @@ Resolve an absolute path from the given `filepath`.
|
|
|
2274
2267
|
|
|
2275
2268
|
**Example**
|
|
2276
2269
|
|
|
2277
|
-
```
|
|
2270
|
+
```html
|
|
2278
2271
|
{{resolve "docs/toc.md"}}
|
|
2279
2272
|
<!-- results in: '/User/dev/docs/toc.md' -->
|
|
2280
2273
|
```
|
|
@@ -2290,7 +2283,7 @@ Get specific (joined) segments of a file path by passing a range of array indice
|
|
|
2290
2283
|
|
|
2291
2284
|
**Example**
|
|
2292
2285
|
|
|
2293
|
-
```
|
|
2286
|
+
```html
|
|
2294
2287
|
{{segments "a/b/c/d" "2" "3"}}
|
|
2295
2288
|
<!-- results in: 'c/d' -->
|
|
2296
2289
|
|
|
@@ -2314,7 +2307,7 @@ Convert the given string to a regular expression.
|
|
|
2314
2307
|
|
|
2315
2308
|
**Example**
|
|
2316
2309
|
|
|
2317
|
-
```
|
|
2310
|
+
```html
|
|
2318
2311
|
{{toRegex "foo"}}
|
|
2319
2312
|
<!-- results in: /foo/ -->
|
|
2320
2313
|
```
|
|
@@ -2330,7 +2323,7 @@ Returns true if the given `str` matches the given regex. A regex can be passed o
|
|
|
2330
2323
|
|
|
2331
2324
|
**Example**
|
|
2332
2325
|
|
|
2333
|
-
```
|
|
2326
|
+
```html
|
|
2334
2327
|
{{test "bar" (toRegex "foo")}}
|
|
2335
2328
|
<!-- results in: false -->
|
|
2336
2329
|
{{test "foobar" (toRegex "foo")}}
|
|
@@ -2353,7 +2346,7 @@ Append the specified `suffix` to the given string.
|
|
|
2353
2346
|
|
|
2354
2347
|
**Example**
|
|
2355
2348
|
|
|
2356
|
-
```
|
|
2349
|
+
```html
|
|
2357
2350
|
<!-- given that "item.stem" is "foo" -->
|
|
2358
2351
|
{{append item.stem ".html"}}
|
|
2359
2352
|
<!-- results in: 'foo.html' -->
|
|
@@ -2370,7 +2363,7 @@ camelCase the characters in the given `string`.
|
|
|
2370
2363
|
|
|
2371
2364
|
**Example**
|
|
2372
2365
|
|
|
2373
|
-
```
|
|
2366
|
+
```html
|
|
2374
2367
|
{{camelcase "foo bar baz"}};
|
|
2375
2368
|
<!-- results in: 'fooBarBaz' -->
|
|
2376
2369
|
```
|
|
@@ -2386,7 +2379,7 @@ Capitalize the first word in a sentence.
|
|
|
2386
2379
|
|
|
2387
2380
|
**Example**
|
|
2388
2381
|
|
|
2389
|
-
```
|
|
2382
|
+
```html
|
|
2390
2383
|
{{capitalize "foo bar baz"}}
|
|
2391
2384
|
<!-- results in: "Foo bar baz" -->
|
|
2392
2385
|
```
|
|
@@ -2402,7 +2395,7 @@ Capitalize all words in a string.
|
|
|
2402
2395
|
|
|
2403
2396
|
**Example**
|
|
2404
2397
|
|
|
2405
|
-
```
|
|
2398
|
+
```html
|
|
2406
2399
|
{{capitalizeAll "foo bar baz"}}
|
|
2407
2400
|
<!-- results in: "Foo Bar Baz" -->
|
|
2408
2401
|
```
|
|
@@ -2428,7 +2421,7 @@ Like trim, but removes both extraneous whitespace **and non-word characters** fr
|
|
|
2428
2421
|
|
|
2429
2422
|
**Example**
|
|
2430
2423
|
|
|
2431
|
-
```
|
|
2424
|
+
```html
|
|
2432
2425
|
{{chop "_ABC_"}}
|
|
2433
2426
|
<!-- results in: 'ABC' -->
|
|
2434
2427
|
|
|
@@ -2450,7 +2443,7 @@ dash-case the characters in `string`. Replaces non-word characters and periods w
|
|
|
2450
2443
|
|
|
2451
2444
|
**Example**
|
|
2452
2445
|
|
|
2453
|
-
```
|
|
2446
|
+
```html
|
|
2454
2447
|
{{dashcase "a-b-c d_e"}}
|
|
2455
2448
|
<!-- results in: 'a-b-c-d-e' -->
|
|
2456
2449
|
```
|
|
@@ -2466,7 +2459,7 @@ dot.case the characters in `string`.
|
|
|
2466
2459
|
|
|
2467
2460
|
**Example**
|
|
2468
2461
|
|
|
2469
|
-
```
|
|
2462
|
+
```html
|
|
2470
2463
|
{{dotcase "a-b-c d_e"}}
|
|
2471
2464
|
<!-- results in: 'a.b.c.d.e' -->
|
|
2472
2465
|
```
|
|
@@ -2482,7 +2475,7 @@ Lowercase all of the characters in the given string. Alias for [lowercase](#lowe
|
|
|
2482
2475
|
|
|
2483
2476
|
**Example**
|
|
2484
2477
|
|
|
2485
|
-
```
|
|
2478
|
+
```html
|
|
2486
2479
|
{{downcase "aBcDeF"}}
|
|
2487
2480
|
<!-- results in: 'abcdef' -->
|
|
2488
2481
|
```
|
|
@@ -2499,7 +2492,7 @@ Truncates a string to the specified `length`, and appends it with an elipsis, `
|
|
|
2499
2492
|
|
|
2500
2493
|
**Example**
|
|
2501
2494
|
|
|
2502
|
-
```
|
|
2495
|
+
```html
|
|
2503
2496
|
{{ellipsis (sanitize "<span>foo bar baz</span>"), 7}}
|
|
2504
2497
|
<!-- results in: 'foo bar…' -->
|
|
2505
2498
|
{{ellipsis "foo bar baz", 7}}
|
|
@@ -2517,7 +2510,7 @@ Replace spaces in a string with hyphens.
|
|
|
2517
2510
|
|
|
2518
2511
|
**Example**
|
|
2519
2512
|
|
|
2520
|
-
```
|
|
2513
|
+
```html
|
|
2521
2514
|
{{hyphenate "foo bar baz qux"}}
|
|
2522
2515
|
<!-- results in: "foo-bar-baz-qux" -->
|
|
2523
2516
|
```
|
|
@@ -2533,7 +2526,7 @@ Return true if `value` is a string.
|
|
|
2533
2526
|
|
|
2534
2527
|
**Example**
|
|
2535
2528
|
|
|
2536
|
-
```
|
|
2529
|
+
```html
|
|
2537
2530
|
{{isString "foo"}}
|
|
2538
2531
|
<!-- results in: 'true' -->
|
|
2539
2532
|
```
|
|
@@ -2549,7 +2542,7 @@ Lowercase all characters in the given string.
|
|
|
2549
2542
|
|
|
2550
2543
|
**Example**
|
|
2551
2544
|
|
|
2552
|
-
```
|
|
2545
|
+
```html
|
|
2553
2546
|
{{lowercase "Foo BAR baZ"}}
|
|
2554
2547
|
<!-- results in: 'foo bar baz' -->
|
|
2555
2548
|
```
|
|
@@ -2566,7 +2559,7 @@ Return the number of occurrences of `substring` within the given `string`.
|
|
|
2566
2559
|
|
|
2567
2560
|
**Example**
|
|
2568
2561
|
|
|
2569
|
-
```
|
|
2562
|
+
```html
|
|
2570
2563
|
{{occurrences "foo bar foo bar baz" "foo"}}
|
|
2571
2564
|
<!-- results in: 2 -->
|
|
2572
2565
|
```
|
|
@@ -2582,7 +2575,7 @@ PascalCase the characters in `string`.
|
|
|
2582
2575
|
|
|
2583
2576
|
**Example**
|
|
2584
2577
|
|
|
2585
|
-
```
|
|
2578
|
+
```html
|
|
2586
2579
|
{{pascalcase "foo bar baz"}}
|
|
2587
2580
|
<!-- results in: 'FooBarBaz' -->
|
|
2588
2581
|
```
|
|
@@ -2598,7 +2591,7 @@ path/case the characters in `string`.
|
|
|
2598
2591
|
|
|
2599
2592
|
**Example**
|
|
2600
2593
|
|
|
2601
|
-
```
|
|
2594
|
+
```html
|
|
2602
2595
|
{{pathcase "a-b-c d_e"}}
|
|
2603
2596
|
<!-- results in: 'a/b/c/d/e' -->
|
|
2604
2597
|
```
|
|
@@ -2614,7 +2607,7 @@ Replace spaces in the given string with pluses.
|
|
|
2614
2607
|
|
|
2615
2608
|
**Example**
|
|
2616
2609
|
|
|
2617
|
-
```
|
|
2610
|
+
```html
|
|
2618
2611
|
{{plusify "foo bar baz"}}
|
|
2619
2612
|
<!-- results in: 'foo+bar+baz' -->
|
|
2620
2613
|
```
|
|
@@ -2631,7 +2624,7 @@ Prepends the given `string` with the specified `prefix`.
|
|
|
2631
2624
|
|
|
2632
2625
|
**Example**
|
|
2633
2626
|
|
|
2634
|
-
```
|
|
2627
|
+
```html
|
|
2635
2628
|
<!-- given that "val" is "bar" -->
|
|
2636
2629
|
{{prepend val "foo-"}}
|
|
2637
2630
|
<!-- results in: 'foo-bar' -->
|
|
@@ -2648,7 +2641,7 @@ Render a block without processing mustache templates inside the block.
|
|
|
2648
2641
|
|
|
2649
2642
|
**Example**
|
|
2650
2643
|
|
|
2651
|
-
```
|
|
2644
|
+
```html
|
|
2652
2645
|
{{{{#raw}}}}
|
|
2653
2646
|
{{foo}}
|
|
2654
2647
|
{{{{/raw}}}}
|
|
@@ -2667,7 +2660,7 @@ Remove all occurrences of `substring` from the given `str`.
|
|
|
2667
2660
|
|
|
2668
2661
|
**Example**
|
|
2669
2662
|
|
|
2670
|
-
```
|
|
2663
|
+
```html
|
|
2671
2664
|
{{remove "a b a b a b" "a "}}
|
|
2672
2665
|
<!-- results in: 'b b b' -->
|
|
2673
2666
|
```
|
|
@@ -2684,7 +2677,7 @@ Remove the first occurrence of `substring` from the given `str`.
|
|
|
2684
2677
|
|
|
2685
2678
|
**Example**
|
|
2686
2679
|
|
|
2687
|
-
```
|
|
2680
|
+
```html
|
|
2688
2681
|
{{remove "a b a b a b" "a"}}
|
|
2689
2682
|
<!-- results in: ' b a b a b' -->
|
|
2690
2683
|
```
|
|
@@ -2702,7 +2695,7 @@ Replace all occurrences of substring `a` with substring `b`.
|
|
|
2702
2695
|
|
|
2703
2696
|
**Example**
|
|
2704
2697
|
|
|
2705
|
-
```
|
|
2698
|
+
```html
|
|
2706
2699
|
{{replace "a b a b a b" "a" "z"}}
|
|
2707
2700
|
<!-- results in: 'z b z b z b' -->
|
|
2708
2701
|
```
|
|
@@ -2720,7 +2713,7 @@ Replace the first occurrence of substring `a` with substring `b`.
|
|
|
2720
2713
|
|
|
2721
2714
|
**Example**
|
|
2722
2715
|
|
|
2723
|
-
```
|
|
2716
|
+
```html
|
|
2724
2717
|
{{replace "a b a b a b" "a" "z"}}
|
|
2725
2718
|
<!-- results in: 'z b a b a b' -->
|
|
2726
2719
|
```
|
|
@@ -2736,7 +2729,7 @@ Reverse a string.
|
|
|
2736
2729
|
|
|
2737
2730
|
**Example**
|
|
2738
2731
|
|
|
2739
|
-
```
|
|
2732
|
+
```html
|
|
2740
2733
|
{{reverse "abcde"}}
|
|
2741
2734
|
<!-- results in: 'edcba' -->
|
|
2742
2735
|
```
|
|
@@ -2752,7 +2745,7 @@ Sentence case the given string
|
|
|
2752
2745
|
|
|
2753
2746
|
**Example**
|
|
2754
2747
|
|
|
2755
|
-
```
|
|
2748
|
+
```html
|
|
2756
2749
|
{{sentence "hello world. goodbye world."}}
|
|
2757
2750
|
<!-- results in: 'Hello world. Goodbye world.' -->
|
|
2758
2751
|
```
|
|
@@ -2768,7 +2761,7 @@ snake_case the characters in the given `string`.
|
|
|
2768
2761
|
|
|
2769
2762
|
**Example**
|
|
2770
2763
|
|
|
2771
|
-
```
|
|
2764
|
+
```html
|
|
2772
2765
|
{{snakecase "a-b-c d_e"}}
|
|
2773
2766
|
<!-- results in: 'a_b_c_d_e' -->
|
|
2774
2767
|
```
|
|
@@ -2784,7 +2777,7 @@ Split `string` by the given `character`.
|
|
|
2784
2777
|
|
|
2785
2778
|
**Example**
|
|
2786
2779
|
|
|
2787
|
-
```
|
|
2780
|
+
```html
|
|
2788
2781
|
{{split "a,b,c" ","}}
|
|
2789
2782
|
<!-- results in: ['a', 'b', 'c'] -->
|
|
2790
2783
|
```
|
|
@@ -2802,7 +2795,7 @@ Tests whether a string begins with the given prefix.
|
|
|
2802
2795
|
|
|
2803
2796
|
**Example**
|
|
2804
2797
|
|
|
2805
|
-
```
|
|
2798
|
+
```html
|
|
2806
2799
|
{{#startsWith "Goodbye" "Hello, world!"}}
|
|
2807
2800
|
Whoops
|
|
2808
2801
|
{{else}}
|
|
@@ -2821,7 +2814,7 @@ Title case the given string.
|
|
|
2821
2814
|
|
|
2822
2815
|
**Example**
|
|
2823
2816
|
|
|
2824
|
-
```
|
|
2817
|
+
```html
|
|
2825
2818
|
{{titleize "this is title case"}}
|
|
2826
2819
|
<!-- results in: 'This Is Title Case' -->
|
|
2827
2820
|
```
|
|
@@ -2837,7 +2830,7 @@ Removes extraneous whitespace from the beginning and end of a string.
|
|
|
2837
2830
|
|
|
2838
2831
|
**Example**
|
|
2839
2832
|
|
|
2840
|
-
```
|
|
2833
|
+
```html
|
|
2841
2834
|
{{trim " ABC "}}
|
|
2842
2835
|
<!-- results in: 'ABC' -->
|
|
2843
2836
|
```
|
|
@@ -2853,7 +2846,7 @@ Removes extraneous whitespace from the beginning of a string.
|
|
|
2853
2846
|
|
|
2854
2847
|
**Example**
|
|
2855
2848
|
|
|
2856
|
-
```
|
|
2849
|
+
```html
|
|
2857
2850
|
{{trim " ABC "}}
|
|
2858
2851
|
<!-- results in: 'ABC ' -->
|
|
2859
2852
|
```
|
|
@@ -2869,7 +2862,7 @@ Removes extraneous whitespace from the end of a string.
|
|
|
2869
2862
|
|
|
2870
2863
|
**Example**
|
|
2871
2864
|
|
|
2872
|
-
```
|
|
2865
|
+
```html
|
|
2873
2866
|
{{trimRight " ABC "}}
|
|
2874
2867
|
<!-- results in: ' ABC' -->
|
|
2875
2868
|
```
|
|
@@ -2887,7 +2880,7 @@ Truncate a string to the specified `length`. Also see [ellipsis](#ellipsis).
|
|
|
2887
2880
|
|
|
2888
2881
|
**Example**
|
|
2889
2882
|
|
|
2890
|
-
```
|
|
2883
|
+
```html
|
|
2891
2884
|
truncate("foo bar baz", 7);
|
|
2892
2885
|
<!-- results in: 'foo bar' -->
|
|
2893
2886
|
truncate(sanitize("<span>foo bar baz</span>", 7));
|
|
@@ -2907,7 +2900,7 @@ Truncate a string to have the specified number of words. Also see [truncate](#tr
|
|
|
2907
2900
|
|
|
2908
2901
|
**Example**
|
|
2909
2902
|
|
|
2910
|
-
```
|
|
2903
|
+
```html
|
|
2911
2904
|
truncateWords("foo bar baz", 1);
|
|
2912
2905
|
<!-- results in: 'foo…' -->
|
|
2913
2906
|
truncateWords("foo bar baz", 2);
|
|
@@ -2927,7 +2920,7 @@ Uppercase all of the characters in the given string. Alias for [uppercase](#uppe
|
|
|
2927
2920
|
|
|
2928
2921
|
**Example**
|
|
2929
2922
|
|
|
2930
|
-
```
|
|
2923
|
+
```html
|
|
2931
2924
|
{{upcase "aBcDeF"}}
|
|
2932
2925
|
<!-- results in: 'ABCDEF' -->
|
|
2933
2926
|
```
|
|
@@ -2944,7 +2937,7 @@ Uppercase all of the characters in the given string. If used as a block helper i
|
|
|
2944
2937
|
|
|
2945
2938
|
**Example**
|
|
2946
2939
|
|
|
2947
|
-
```
|
|
2940
|
+
```html
|
|
2948
2941
|
{{uppercase "aBcDeF"}}
|
|
2949
2942
|
<!-- results in: 'ABCDEF' -->
|
|
2950
2943
|
```
|
|
@@ -3030,7 +3023,7 @@ Strip protocol from a `url`. Useful for displaying media that may have an 'http'
|
|
|
3030
3023
|
|
|
3031
3024
|
**Example**
|
|
3032
3025
|
|
|
3033
|
-
```
|
|
3026
|
+
```html
|
|
3034
3027
|
<!-- url = 'http://foo.bar' -->
|
|
3035
3028
|
{{stripProtocol url}}
|
|
3036
3029
|
<!-- results in: '//foo.bar' -->
|
|
@@ -3053,7 +3046,7 @@ Change casing on the given `string`, optionally passing a delimiter to use betwe
|
|
|
3053
3046
|
|
|
3054
3047
|
**Example**
|
|
3055
3048
|
|
|
3056
|
-
```
|
|
3049
|
+
```html
|
|
3057
3050
|
utils.changecase('fooBarBaz');
|
|
3058
3051
|
//=> 'foo bar baz'
|
|
3059
3052
|
|
|
@@ -3071,10 +3064,8 @@ Generate a random number
|
|
|
3071
3064
|
* `max` **{Number}**
|
|
3072
3065
|
* `returns` **{Number}**
|
|
3073
3066
|
|
|
3074
|
-
***
|
|
3075
|
-
|
|
3076
3067
|
## How to Contribute
|
|
3077
|
-
Now that you've set up your workspace, you're ready to contribute changes to the `fumanchu` repository you can refer to the [CONTRIBUTING](CONTRIBUTING.md) guide. If you have any questions please feel free to ask by creating an issue and label it `question`.
|
|
3068
|
+
clone the repository locally and run 'npm i' in the root. Now that you've set up your workspace, you're ready to contribute changes to the `fumanchu` repository you can refer to the [CONTRIBUTING](CONTRIBUTING.md) guide. If you have any questions please feel free to ask by creating an issue and label it `question`.
|
|
3078
3069
|
|
|
3079
3070
|
## License and Copyright
|
|
3080
3071
|
[MIT](LICENSE) and codebase after 2023 will be copyright of Jared Wray.
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import HandlebarsLib from 'handlebars';
|
|
2
|
+
declare const handlebars: typeof HandlebarsLib;
|
|
3
|
+
declare let handlebarHelpers: any;
|
|
4
|
+
export default handlebars;
|
|
5
|
+
export { handlebarHelpers };
|
package/index.mjs
CHANGED
|
@@ -2,10 +2,15 @@ import HandlebarsLib from 'handlebars';
|
|
|
2
2
|
|
|
3
3
|
const handlebars = HandlebarsLib.create();
|
|
4
4
|
|
|
5
|
+
// Variable to hold the helpers function
|
|
6
|
+
let handlebarHelpers;
|
|
7
|
+
|
|
5
8
|
import('./helpers.js').then((module) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
handlebarHelpers = module.default;
|
|
10
|
+
handlebarHelpers({ handlebars: handlebars });
|
|
11
|
+
});
|
|
9
12
|
|
|
10
13
|
// Exporting for ESM
|
|
11
14
|
export default handlebars;
|
|
15
|
+
export { handlebarHelpers };
|
|
16
|
+
|
package/lib/markdown.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const hljs = require('highlight.js');
|
|
3
|
+
const utils = require('handlebars-utils');
|
|
4
|
+
const {Remarkable} = require('remarkable');
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Expose markdown `helpers` (for performance we're using getters so
|
|
@@ -34,7 +37,7 @@ Object.defineProperty(helpers, 'markdown', {
|
|
|
34
37
|
get: function() {
|
|
35
38
|
// this is defined as a getter to avoid calling this function
|
|
36
39
|
// unless the helper is actually used
|
|
37
|
-
return markdown || (markdown =
|
|
40
|
+
return markdown || (markdown = this.helpersForMarkdown());
|
|
38
41
|
}
|
|
39
42
|
});
|
|
40
43
|
|
|
@@ -52,4 +55,45 @@ Object.defineProperty(helpers, 'markdown', {
|
|
|
52
55
|
* @api public
|
|
53
56
|
*/
|
|
54
57
|
|
|
55
|
-
helpers.md = require('
|
|
58
|
+
helpers.md = require('./md.js');
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
helpers.helpersForMarkdown = function(config) {
|
|
62
|
+
const defaults = { html: true, breaks: true, highlight: helpers.highlightFormMarkdown };
|
|
63
|
+
if (typeof config === 'string' || utils.isOptions(config)) {
|
|
64
|
+
return markdown.apply(defaults, arguments);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function markdown(str, locals, options) {
|
|
68
|
+
if (typeof str !== 'string') {
|
|
69
|
+
options = locals;
|
|
70
|
+
locals = str;
|
|
71
|
+
str = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (utils.isOptions(locals)) {
|
|
75
|
+
options = locals;
|
|
76
|
+
locals = {};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const ctx = utils.context(this, locals, options);
|
|
80
|
+
let opts = utils.options(this, locals, options);
|
|
81
|
+
opts = Object.assign({}, defaults, config, opts);
|
|
82
|
+
|
|
83
|
+
if (opts.hasOwnProperty('lang')) {
|
|
84
|
+
opts.langPrefix = opts.lang;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const md = new Remarkable(opts);
|
|
88
|
+
const val = utils.value(str, ctx, options);
|
|
89
|
+
return md.render(val);
|
|
90
|
+
}
|
|
91
|
+
return markdown;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
helpers.highlightFormMarkdown = function(code, lang) {
|
|
95
|
+
if(lang) {
|
|
96
|
+
return hljs.highlight(code, {language: lang}).value;
|
|
97
|
+
}
|
|
98
|
+
return hljs.highlightAuto(code).value;
|
|
99
|
+
}
|
package/lib/md.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* helper-markdown <https://github.com/jonschlinkert/helper-markdown>
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2014 Jon Schlinkert, contributors.
|
|
5
|
+
* Licensed under the MIT license.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var fs = require('fs');
|
|
11
|
+
var path = require('path');
|
|
12
|
+
const { Remarkable } = require('remarkable');
|
|
13
|
+
var extend = require('extend-shallow');
|
|
14
|
+
var exists = require('fs-exists-sync');
|
|
15
|
+
var ent = require('ent');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Expose `md` helper
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var helper = module.exports = function(name, options, cb) {
|
|
22
|
+
if (typeof options === 'function') {
|
|
23
|
+
cb = options;
|
|
24
|
+
options = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof cb !== 'function') {
|
|
28
|
+
return helper.sync.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* c8 ignore next 3 */
|
|
32
|
+
if (typeof this === 'undefined' || typeof this.app === 'undefined') {
|
|
33
|
+
throw new Error('md async helper expects `app` to be exposed on the context');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var opts = extend({cwd: process.cwd()}, this.options, options);
|
|
37
|
+
opts = extend({}, opts, opts.hash);
|
|
38
|
+
var md = markdown(opts);
|
|
39
|
+
|
|
40
|
+
var filepath = path.resolve(opts.cwd, name);
|
|
41
|
+
var view;
|
|
42
|
+
var str = '';
|
|
43
|
+
|
|
44
|
+
if (exists(filepath)) {
|
|
45
|
+
// create a collection to ensure middleware is consistent
|
|
46
|
+
this.app.create('mdfiles');
|
|
47
|
+
str = fs.readFileSync(filepath, 'utf8');
|
|
48
|
+
view = this.app.mdfile(filepath, {path: filepath, content: str});
|
|
49
|
+
} else {
|
|
50
|
+
view = this.app.find(name);
|
|
51
|
+
}
|
|
52
|
+
/* c8 ignore next 4 */
|
|
53
|
+
if (typeof view === 'undefined') {
|
|
54
|
+
cb(null, '');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
view.content = ent.decode(md.render(view.content));
|
|
59
|
+
this.app.render(view, this.context, function(err, res) {
|
|
60
|
+
if (err) return cb(err);
|
|
61
|
+
cb(null, res.content);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
helper.sync = function(name, options) {
|
|
66
|
+
var ctx = this || {};
|
|
67
|
+
var app = ctx.app || {};
|
|
68
|
+
|
|
69
|
+
var opts = extend({cwd: process.cwd()}, ctx.options, options);
|
|
70
|
+
opts = extend({}, opts, opts.hash);
|
|
71
|
+
var md = markdown(opts);
|
|
72
|
+
|
|
73
|
+
var filepath = path.resolve(opts.cwd, name);
|
|
74
|
+
var view;
|
|
75
|
+
var html = '';
|
|
76
|
+
var str = '';
|
|
77
|
+
|
|
78
|
+
if (exists(filepath)) {
|
|
79
|
+
str = fs.readFileSync(filepath, 'utf8');
|
|
80
|
+
html = ent.decode(md.render(str));
|
|
81
|
+
} else if (app.views) {
|
|
82
|
+
view = app.find(name);
|
|
83
|
+
if (view) {
|
|
84
|
+
html = view.content = ent.decode(md.render(view.content));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (view && typeof view.compile === 'function') {
|
|
89
|
+
view.compile(opts);
|
|
90
|
+
var data = ctx.cache ? ctx.cache.data : {};
|
|
91
|
+
ctx = extend({}, data, view.data);
|
|
92
|
+
return view.fn(ctx);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (typeof this.compile === 'function') {
|
|
96
|
+
var fn = this.compile(html);
|
|
97
|
+
return fn(this);
|
|
98
|
+
}
|
|
99
|
+
return html;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Shared settings for remarkable
|
|
104
|
+
*
|
|
105
|
+
* @param {Object} `options`
|
|
106
|
+
* @return {Object}
|
|
107
|
+
* @api private
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
function markdown(options) {
|
|
111
|
+
let optsConfig = options || {};
|
|
112
|
+
optsConfig.breaks = true;
|
|
113
|
+
optsConfig.html = true;
|
|
114
|
+
optsConfig.langPrefix = 'lang-';
|
|
115
|
+
optsConfig.typographer = false;
|
|
116
|
+
optsConfig.xhtmlOut = false;
|
|
117
|
+
const md = new Remarkable(optsConfig);
|
|
118
|
+
return md;
|
|
119
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaredwray/fumanchu",
|
|
3
3
|
"description": "Handlebars + Helpers = Fumanchu",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"homepage": "https://github.com/jaredwray/fumanchu",
|
|
6
6
|
"author": "Jared Wray (me@jaredwray.com)",
|
|
7
7
|
"keywords": [
|
|
@@ -109,14 +109,15 @@
|
|
|
109
109
|
"test": "c8 mocha --reporter list",
|
|
110
110
|
"test:ci": "c8 --reporter=lcov mocha --reporter list",
|
|
111
111
|
"clean": "rimraf ./node_modules ./coverage yarn.lock package-lock.json",
|
|
112
|
-
"website:build": "rimraf ./site/readme.md && npx -y
|
|
113
|
-
"website:serve": "rimraf ./site/readme.md && npx -y
|
|
112
|
+
"website:build": "rimraf ./site/readme.md && npx -y docula build -s ./site -o ./dist-site",
|
|
113
|
+
"website:serve": "rimraf ./site/readme.md && npx -y docula serve -s ./site -o ./dist-site"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
116
|
"arr-flatten": "^1.1.0",
|
|
117
117
|
"array-sort": "^1.0.0",
|
|
118
118
|
"create-frame": "^1.0.0",
|
|
119
119
|
"define-property": "^2.0.2",
|
|
120
|
+
"ent": "^2.2.0",
|
|
120
121
|
"falsey": "^1.0.0",
|
|
121
122
|
"for-in": "^1.0.2",
|
|
122
123
|
"for-own": "^1.0.0",
|
|
@@ -127,8 +128,7 @@
|
|
|
127
128
|
"handlebars-utils": "^1.0.6",
|
|
128
129
|
"has-value": "^2.0.2",
|
|
129
130
|
"helper-date": "^1.0.1",
|
|
130
|
-
"
|
|
131
|
-
"helper-md": "^0.2.2",
|
|
131
|
+
"highlight.js": "^11.9.0",
|
|
132
132
|
"html-tag": "^2.0.0",
|
|
133
133
|
"is-even": "^1.0.0",
|
|
134
134
|
"is-glob": "^4.0.3",
|
|
@@ -136,19 +136,21 @@
|
|
|
136
136
|
"kind-of": "^6.0.3",
|
|
137
137
|
"lazy-cache": "^2.0.2",
|
|
138
138
|
"logging-helpers": "^1.0.0",
|
|
139
|
-
"micromatch": "^4.0.
|
|
139
|
+
"micromatch": "^4.0.7",
|
|
140
140
|
"relative": "^3.0.2",
|
|
141
|
+
"remarkable": "^2.0.1",
|
|
141
142
|
"striptags": "^3.2.0",
|
|
142
143
|
"to-gfm-code-block": "^0.1.1",
|
|
143
144
|
"year": "^0.2.1"
|
|
144
145
|
},
|
|
145
146
|
"devDependencies": {
|
|
146
|
-
"c8": "^
|
|
147
|
+
"c8": "^10.1.2",
|
|
147
148
|
"chai": "^4.3.10",
|
|
148
|
-
"
|
|
149
|
-
"mocha": "^10.
|
|
150
|
-
"rimraf": "^5.0.
|
|
149
|
+
"lodash": "^4.17.21",
|
|
150
|
+
"mocha": "^10.4.0",
|
|
151
|
+
"rimraf": "^5.0.7",
|
|
151
152
|
"template-helpers": "^1.0.1",
|
|
152
|
-
"templates": "^1.2.9"
|
|
153
|
+
"templates": "^1.2.9",
|
|
154
|
+
"typescript": "^5.5.2"
|
|
153
155
|
}
|
|
154
156
|
}
|