handlebarsjs 0.5.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/.templates/helper.rb +31 -0
- data/.builders/.templates/helper_spec.rb +38 -0
- data/.builders/_.rb +3 -1
- data/.builders/boot.rb +2 -2
- data/.builders/director/handlebars_helper_builder.rb +67 -0
- data/.builders/director/handlebars_helper_child.rb +67 -0
- data/.builders/director/handlebars_helper_director.rb +24 -0
- data/.builders/generators/helpers/comparison_helpers.rb +44 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +8 -0
- data/docs/domain_model.drawio +32 -32
- data/docs/domain_model.json +57 -57
- data/docs/project-plan/project.drawio +16 -16
- data/lib/_.rb +34 -0
- data/lib/handlebarsjs/base_helper.rb +21 -8
- data/lib/handlebarsjs/handlebars_snapshot.rb +4 -6
- data/lib/handlebarsjs/helpers/array/join.rb +17 -0
- data/lib/handlebarsjs/helpers/array/join_post.rb +17 -0
- data/lib/handlebarsjs/helpers/array/join_pre.rb +17 -0
- data/lib/handlebarsjs/helpers/case/back_slash.rb +17 -0
- data/lib/handlebarsjs/helpers/case/camel.rb +17 -0
- data/lib/handlebarsjs/helpers/case/constant.rb +17 -0
- data/lib/handlebarsjs/helpers/case/dash.rb +17 -0
- data/lib/handlebarsjs/helpers/case/dot.rb +17 -0
- data/lib/handlebarsjs/helpers/case/double_colon.rb +17 -0
- data/lib/handlebarsjs/helpers/case/human.rb +17 -0
- data/lib/handlebarsjs/helpers/case/lamel.rb +17 -0
- data/lib/handlebarsjs/helpers/case/lower.rb +17 -0
- data/lib/handlebarsjs/helpers/case/slash.rb +17 -0
- data/lib/handlebarsjs/helpers/case/snake.rb +17 -0
- data/lib/handlebarsjs/helpers/case/title.rb +17 -0
- data/lib/handlebarsjs/helpers/case/upper.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/and.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/default.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/eq.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/gt.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/gte.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/lt.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/lte.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/ne.rb +17 -0
- data/lib/handlebarsjs/helpers/comparison/or.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/ordinal.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/ordinalize.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/pluralize.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/pluralize_by_number.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/pluralize_number.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/pluralize_number_word.rb +17 -0
- data/lib/handlebarsjs/helpers/inflection/singularize.rb +17 -0
- data/lib/handlebarsjs/version.rb +1 -1
- data/lib/handlebarsjs.rb +2 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +58 -2
data/docs/domain_model.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"host": "
|
2
|
+
"host": "jWj",
|
3
3
|
"theme": "style_04",
|
4
4
|
"palette": {
|
5
5
|
"fill_color": "#ffe6cc",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
},
|
18
18
|
"pages": [
|
19
19
|
{
|
20
|
-
"id": "
|
20
|
+
"id": "rZL",
|
21
21
|
"active": true,
|
22
22
|
"name": "Domain Modal",
|
23
23
|
"position_x": 0,
|
@@ -58,20 +58,20 @@
|
|
58
58
|
},
|
59
59
|
"nodes": [
|
60
60
|
{
|
61
|
-
"id": "
|
62
|
-
"parent_id": "
|
61
|
+
"id": "page_root_rZL",
|
62
|
+
"parent_id": "rZL",
|
63
63
|
"classification": "anchor",
|
64
64
|
"key": "page_root",
|
65
65
|
"nodes": [
|
66
66
|
{
|
67
|
-
"id": "
|
68
|
-
"parent_id": "
|
67
|
+
"id": "node_root_rZL",
|
68
|
+
"parent_id": "page_root_rZL",
|
69
69
|
"classification": "anchor",
|
70
70
|
"key": "node_root",
|
71
71
|
"nodes": [
|
72
72
|
{
|
73
73
|
"id": "rule-2",
|
74
|
-
"parent_id": "
|
74
|
+
"parent_id": "node_root_rZL",
|
75
75
|
"classification": "layout_rule",
|
76
76
|
"key": "grid_layout",
|
77
77
|
"anchor_x": 0,
|
@@ -83,8 +83,8 @@
|
|
83
83
|
"cell_no": 1
|
84
84
|
},
|
85
85
|
{
|
86
|
-
"id": "
|
87
|
-
"parent_id": "
|
86
|
+
"id": "rZL-2",
|
87
|
+
"parent_id": "node_root_rZL",
|
88
88
|
"classification": "shape",
|
89
89
|
"key": "klass",
|
90
90
|
"x": 10,
|
@@ -115,8 +115,8 @@
|
|
115
115
|
}
|
116
116
|
},
|
117
117
|
{
|
118
|
-
"id": "
|
119
|
-
"parent_id": "
|
118
|
+
"id": "rZL-3",
|
119
|
+
"parent_id": "node_root_rZL",
|
120
120
|
"classification": "shape",
|
121
121
|
"key": "klass",
|
122
122
|
"x": 190,
|
@@ -147,8 +147,8 @@
|
|
147
147
|
}
|
148
148
|
},
|
149
149
|
{
|
150
|
-
"id": "
|
151
|
-
"parent_id": "
|
150
|
+
"id": "rZL-4",
|
151
|
+
"parent_id": "node_root_rZL",
|
152
152
|
"classification": "shape",
|
153
153
|
"key": "klass",
|
154
154
|
"x": 370,
|
@@ -204,8 +204,8 @@
|
|
204
204
|
}
|
205
205
|
},
|
206
206
|
{
|
207
|
-
"id": "
|
208
|
-
"parent_id": "
|
207
|
+
"id": "rZL-5",
|
208
|
+
"parent_id": "node_root_rZL",
|
209
209
|
"classification": "shape",
|
210
210
|
"key": "klass",
|
211
211
|
"x": 550,
|
@@ -226,8 +226,8 @@
|
|
226
226
|
}
|
227
227
|
},
|
228
228
|
{
|
229
|
-
"id": "
|
230
|
-
"parent_id": "
|
229
|
+
"id": "rZL-6",
|
230
|
+
"parent_id": "node_root_rZL",
|
231
231
|
"classification": "shape",
|
232
232
|
"key": "square",
|
233
233
|
"x": 805,
|
@@ -246,8 +246,8 @@
|
|
246
246
|
}
|
247
247
|
},
|
248
248
|
{
|
249
|
-
"id": "
|
250
|
-
"parent_id": "
|
249
|
+
"id": "rZL-7",
|
250
|
+
"parent_id": "node_root_rZL",
|
251
251
|
"classification": "shape",
|
252
252
|
"key": "square",
|
253
253
|
"x": 985,
|
@@ -267,7 +267,7 @@
|
|
267
267
|
},
|
268
268
|
{
|
269
269
|
"id": "rule-2",
|
270
|
-
"parent_id": "
|
270
|
+
"parent_id": "node_root_rZL",
|
271
271
|
"classification": "layout_rule",
|
272
272
|
"key": "grid_layout",
|
273
273
|
"anchor_x": 0,
|
@@ -280,7 +280,7 @@
|
|
280
280
|
},
|
281
281
|
{
|
282
282
|
"id": "a1",
|
283
|
-
"parent_id": "
|
283
|
+
"parent_id": "node_root_rZL",
|
284
284
|
"classification": "shape",
|
285
285
|
"key": "square",
|
286
286
|
"x": 10,
|
@@ -300,7 +300,7 @@
|
|
300
300
|
},
|
301
301
|
{
|
302
302
|
"id": "a2",
|
303
|
-
"parent_id": "
|
303
|
+
"parent_id": "node_root_rZL",
|
304
304
|
"classification": "shape",
|
305
305
|
"key": "square",
|
306
306
|
"x": 110,
|
@@ -320,7 +320,7 @@
|
|
320
320
|
},
|
321
321
|
{
|
322
322
|
"id": "a3",
|
323
|
-
"parent_id": "
|
323
|
+
"parent_id": "node_root_rZL",
|
324
324
|
"classification": "shape",
|
325
325
|
"key": "square",
|
326
326
|
"x": 210,
|
@@ -340,7 +340,7 @@
|
|
340
340
|
},
|
341
341
|
{
|
342
342
|
"id": "a4",
|
343
|
-
"parent_id": "
|
343
|
+
"parent_id": "node_root_rZL",
|
344
344
|
"classification": "shape",
|
345
345
|
"key": "square",
|
346
346
|
"x": 310,
|
@@ -360,7 +360,7 @@
|
|
360
360
|
},
|
361
361
|
{
|
362
362
|
"id": "a5",
|
363
|
-
"parent_id": "
|
363
|
+
"parent_id": "node_root_rZL",
|
364
364
|
"classification": "shape",
|
365
365
|
"key": "square",
|
366
366
|
"x": 410,
|
@@ -380,7 +380,7 @@
|
|
380
380
|
},
|
381
381
|
{
|
382
382
|
"id": "a6",
|
383
|
-
"parent_id": "
|
383
|
+
"parent_id": "node_root_rZL",
|
384
384
|
"classification": "shape",
|
385
385
|
"key": "square",
|
386
386
|
"x": 510,
|
@@ -400,7 +400,7 @@
|
|
400
400
|
},
|
401
401
|
{
|
402
402
|
"id": "a7",
|
403
|
-
"parent_id": "
|
403
|
+
"parent_id": "node_root_rZL",
|
404
404
|
"classification": "shape",
|
405
405
|
"key": "square",
|
406
406
|
"x": 10,
|
@@ -420,7 +420,7 @@
|
|
420
420
|
},
|
421
421
|
{
|
422
422
|
"id": "a8",
|
423
|
-
"parent_id": "
|
423
|
+
"parent_id": "node_root_rZL",
|
424
424
|
"classification": "shape",
|
425
425
|
"key": "square",
|
426
426
|
"x": 110,
|
@@ -439,8 +439,8 @@
|
|
439
439
|
}
|
440
440
|
},
|
441
441
|
{
|
442
|
-
"id": "
|
443
|
-
"parent_id": "
|
442
|
+
"id": "rZL-17",
|
443
|
+
"parent_id": "node_root_rZL",
|
444
444
|
"classification": "shape",
|
445
445
|
"key": "solid",
|
446
446
|
"x": 0,
|
@@ -459,8 +459,8 @@
|
|
459
459
|
}
|
460
460
|
},
|
461
461
|
{
|
462
|
-
"id": "
|
463
|
-
"parent_id": "
|
462
|
+
"id": "rZL-18",
|
463
|
+
"parent_id": "node_root_rZL",
|
464
464
|
"classification": "shape",
|
465
465
|
"key": "solid",
|
466
466
|
"x": 0,
|
@@ -479,8 +479,8 @@
|
|
479
479
|
}
|
480
480
|
},
|
481
481
|
{
|
482
|
-
"id": "
|
483
|
-
"parent_id": "
|
482
|
+
"id": "rZL-19",
|
483
|
+
"parent_id": "node_root_rZL",
|
484
484
|
"classification": "shape",
|
485
485
|
"key": "solid",
|
486
486
|
"x": 0,
|
@@ -499,8 +499,8 @@
|
|
499
499
|
}
|
500
500
|
},
|
501
501
|
{
|
502
|
-
"id": "
|
503
|
-
"parent_id": "
|
502
|
+
"id": "rZL-20",
|
503
|
+
"parent_id": "node_root_rZL",
|
504
504
|
"classification": "shape",
|
505
505
|
"key": "solid",
|
506
506
|
"x": 0,
|
@@ -519,8 +519,8 @@
|
|
519
519
|
}
|
520
520
|
},
|
521
521
|
{
|
522
|
-
"id": "
|
523
|
-
"parent_id": "
|
522
|
+
"id": "rZL-21",
|
523
|
+
"parent_id": "node_root_rZL",
|
524
524
|
"classification": "shape",
|
525
525
|
"key": "solid",
|
526
526
|
"x": 0,
|
@@ -539,8 +539,8 @@
|
|
539
539
|
}
|
540
540
|
},
|
541
541
|
{
|
542
|
-
"id": "
|
543
|
-
"parent_id": "
|
542
|
+
"id": "rZL-22",
|
543
|
+
"parent_id": "node_root_rZL",
|
544
544
|
"classification": "shape",
|
545
545
|
"key": "solid",
|
546
546
|
"x": 0,
|
@@ -559,8 +559,8 @@
|
|
559
559
|
}
|
560
560
|
},
|
561
561
|
{
|
562
|
-
"id": "
|
563
|
-
"parent_id": "
|
562
|
+
"id": "rZL-23",
|
563
|
+
"parent_id": "node_root_rZL",
|
564
564
|
"classification": "shape",
|
565
565
|
"key": "solid",
|
566
566
|
"x": 0,
|
@@ -579,8 +579,8 @@
|
|
579
579
|
}
|
580
580
|
},
|
581
581
|
{
|
582
|
-
"id": "
|
583
|
-
"parent_id": "
|
582
|
+
"id": "rZL-24",
|
583
|
+
"parent_id": "node_root_rZL",
|
584
584
|
"classification": "shape",
|
585
585
|
"key": "solid",
|
586
586
|
"x": 0,
|
@@ -599,8 +599,8 @@
|
|
599
599
|
}
|
600
600
|
},
|
601
601
|
{
|
602
|
-
"id": "
|
603
|
-
"parent_id": "
|
602
|
+
"id": "rZL-25",
|
603
|
+
"parent_id": "node_root_rZL",
|
604
604
|
"classification": "shape",
|
605
605
|
"key": "square",
|
606
606
|
"x": 245,
|
@@ -619,8 +619,8 @@
|
|
619
619
|
}
|
620
620
|
},
|
621
621
|
{
|
622
|
-
"id": "
|
623
|
-
"parent_id": "
|
622
|
+
"id": "rZL-26",
|
623
|
+
"parent_id": "node_root_rZL",
|
624
624
|
"classification": "shape",
|
625
625
|
"key": "square",
|
626
626
|
"x": 345,
|
@@ -639,8 +639,8 @@
|
|
639
639
|
}
|
640
640
|
},
|
641
641
|
{
|
642
|
-
"id": "
|
643
|
-
"parent_id": "
|
642
|
+
"id": "rZL-27",
|
643
|
+
"parent_id": "node_root_rZL",
|
644
644
|
"classification": "shape",
|
645
645
|
"key": "square",
|
646
646
|
"x": 445,
|
@@ -659,8 +659,8 @@
|
|
659
659
|
}
|
660
660
|
},
|
661
661
|
{
|
662
|
-
"id": "
|
663
|
-
"parent_id": "
|
662
|
+
"id": "rZL-28",
|
663
|
+
"parent_id": "node_root_rZL",
|
664
664
|
"classification": "shape",
|
665
665
|
"key": "square",
|
666
666
|
"x": 545,
|
@@ -680,7 +680,7 @@
|
|
680
680
|
},
|
681
681
|
{
|
682
682
|
"id": "rule-2",
|
683
|
-
"parent_id": "
|
683
|
+
"parent_id": "node_root_rZL",
|
684
684
|
"classification": "layout_rule",
|
685
685
|
"key": "grid_layout",
|
686
686
|
"anchor_x": 0,
|
@@ -692,8 +692,8 @@
|
|
692
692
|
"cell_no": 1
|
693
693
|
},
|
694
694
|
{
|
695
|
-
"id": "
|
696
|
-
"parent_id": "
|
695
|
+
"id": "rZL-30",
|
696
|
+
"parent_id": "node_root_rZL",
|
697
697
|
"classification": "shape",
|
698
698
|
"key": "group",
|
699
699
|
"x": 25,
|
@@ -712,8 +712,8 @@
|
|
712
712
|
}
|
713
713
|
},
|
714
714
|
{
|
715
|
-
"id": "
|
716
|
-
"parent_id": "
|
715
|
+
"id": "rZL-31",
|
716
|
+
"parent_id": "node_root_rZL",
|
717
717
|
"classification": "shape",
|
718
718
|
"key": "group",
|
719
719
|
"x": 25,
|
@@ -1,43 +1,43 @@
|
|
1
|
-
<mxfile host="
|
2
|
-
<diagram id="
|
1
|
+
<mxfile host="e73">
|
2
|
+
<diagram id="QdY" name="In progress">
|
3
3
|
<mxGraphModel dx="0" dy="0" background="#FFFAFA" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
4
4
|
<root>
|
5
|
-
<mxCell id="
|
6
|
-
<mxCell id="
|
7
|
-
<mxCell id="
|
5
|
+
<mxCell id="page_root_QdY" parent="QdY"/>
|
6
|
+
<mxCell id="node_root_QdY" parent="page_root_QdY"/>
|
7
|
+
<mxCell id="QdY-1" value="DrawIO DSL" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fontColor=#1F2D3D;text;fontSize=28;fontStyle=1;fillColor=none" vertex="1" parent="node_root_QdY">
|
8
8
|
<mxGeometry x="300" y="0" width="400" height="80" as="geometry"/>
|
9
9
|
</mxCell>
|
10
|
-
<mxCell id="
|
10
|
+
<mxCell id="QdY-3" value="add miniracer to gem and test sample JS with snapshot" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_QdY">
|
11
11
|
<mxGeometry x="10" y="10" width="300" height="60" as="geometry"/>
|
12
12
|
</mxCell>
|
13
|
-
<mxCell id="
|
13
|
+
<mxCell id="QdY-4" value="add handlebarsjs file and load into snapshot" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_QdY">
|
14
14
|
<mxGeometry x="330" y="10" width="300" height="60" as="geometry"/>
|
15
15
|
</mxCell>
|
16
|
-
<mxCell id="
|
16
|
+
<mxCell id="QdY-5" value="get handlebars working with simple templates" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_QdY">
|
17
17
|
<mxGeometry x="650" y="10" width="300" height="60" as="geometry"/>
|
18
18
|
</mxCell>
|
19
|
-
<mxCell id="
|
19
|
+
<mxCell id="QdY-6" value="write a simple handlebars help in ruby" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_QdY">
|
20
20
|
<mxGeometry x="10" y="90" width="300" height="60" as="geometry"/>
|
21
21
|
</mxCell>
|
22
|
-
<mxCell id="
|
22
|
+
<mxCell id="QdY-7" value="add project plan markdown to this gem and template" style="whiteSpace=wrap;html=1;rounded=1;glass=1;fillColor=#d5e8d4;strokeColor=#82b366;fontColor=#333333" vertex="1" parent="node_root_QdY">
|
23
23
|
<mxGeometry x="330" y="90" width="300" height="60" as="geometry"/>
|
24
24
|
</mxCell>
|
25
25
|
</root>
|
26
26
|
</mxGraphModel>
|
27
27
|
</diagram>
|
28
|
-
<diagram id="
|
28
|
+
<diagram id="GVc" name="To Do">
|
29
29
|
<mxGraphModel dx="0" dy="0" background="#FFFAFA" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
30
30
|
<root>
|
31
|
-
<mxCell id="
|
32
|
-
<mxCell id="
|
31
|
+
<mxCell id="page_root_GVc" parent="GVc"/>
|
32
|
+
<mxCell id="node_root_GVc" parent="page_root_GVc"/>
|
33
33
|
</root>
|
34
34
|
</mxGraphModel>
|
35
35
|
</diagram>
|
36
|
-
<diagram id="
|
36
|
+
<diagram id="yFX" name="Done">
|
37
37
|
<mxGraphModel dx="0" dy="0" background="#FFFAFA" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
38
38
|
<root>
|
39
|
-
<mxCell id="
|
40
|
-
<mxCell id="
|
39
|
+
<mxCell id="page_root_yFX" parent="yFX"/>
|
40
|
+
<mxCell id="node_root_yFX" parent="page_root_yFX"/>
|
41
41
|
</root>
|
42
42
|
</mxGraphModel>
|
43
43
|
</diagram>
|
data/lib/_.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'handlebarsjs/helpers/array/join'
|
4
|
+
require_relative 'handlebarsjs/helpers/array/join_post'
|
5
|
+
require_relative 'handlebarsjs/helpers/array/join_pre'
|
6
|
+
require_relative 'handlebarsjs/helpers/case/back_slash'
|
7
|
+
require_relative 'handlebarsjs/helpers/case/camel'
|
8
|
+
require_relative 'handlebarsjs/helpers/case/constant'
|
9
|
+
require_relative 'handlebarsjs/helpers/case/dash'
|
10
|
+
require_relative 'handlebarsjs/helpers/case/dot'
|
11
|
+
require_relative 'handlebarsjs/helpers/case/double_colon'
|
12
|
+
require_relative 'handlebarsjs/helpers/case/human'
|
13
|
+
require_relative 'handlebarsjs/helpers/case/lamel'
|
14
|
+
require_relative 'handlebarsjs/helpers/case/lower'
|
15
|
+
require_relative 'handlebarsjs/helpers/case/slash'
|
16
|
+
require_relative 'handlebarsjs/helpers/case/snake'
|
17
|
+
require_relative 'handlebarsjs/helpers/case/title'
|
18
|
+
require_relative 'handlebarsjs/helpers/case/upper'
|
19
|
+
require_relative 'handlebarsjs/helpers/comparison/and'
|
20
|
+
require_relative 'handlebarsjs/helpers/comparison/default'
|
21
|
+
require_relative 'handlebarsjs/helpers/comparison/eq'
|
22
|
+
require_relative 'handlebarsjs/helpers/comparison/gt'
|
23
|
+
require_relative 'handlebarsjs/helpers/comparison/gte'
|
24
|
+
require_relative 'handlebarsjs/helpers/comparison/lt'
|
25
|
+
require_relative 'handlebarsjs/helpers/comparison/lte'
|
26
|
+
require_relative 'handlebarsjs/helpers/comparison/ne'
|
27
|
+
require_relative 'handlebarsjs/helpers/comparison/or'
|
28
|
+
require_relative 'handlebarsjs/helpers/inflection/ordinal'
|
29
|
+
require_relative 'handlebarsjs/helpers/inflection/ordinalize'
|
30
|
+
require_relative 'handlebarsjs/helpers/inflection/pluralize'
|
31
|
+
require_relative 'handlebarsjs/helpers/inflection/pluralize_by_number'
|
32
|
+
require_relative 'handlebarsjs/helpers/inflection/pluralize_number'
|
33
|
+
require_relative 'handlebarsjs/helpers/inflection/pluralize_number_word'
|
34
|
+
require_relative 'handlebarsjs/helpers/inflection/singularize'
|
@@ -3,16 +3,22 @@
|
|
3
3
|
module Handlebarsjs
|
4
4
|
# Extend base helper for each of your custom handlebars-helpers
|
5
5
|
class BaseHelper
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
6
|
+
attr_reader :cmdlet
|
7
|
+
|
8
|
+
# Preferred way to register the internal command is via register_cmdlet
|
9
|
+
# but you can also register the command directly in the initializer and
|
10
|
+
# that can be handy if you use a custom configured cmdlet
|
11
|
+
def initialize(cmdlet = nil)
|
12
|
+
@cmdlet = cmdlet
|
13
|
+
@cmdlet = self.class.cmdlet.new if @cmdlet.nil? && self.class.cmdlet
|
11
14
|
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
class << self
|
17
|
+
attr_reader :cmdlet
|
18
|
+
|
19
|
+
def register_cmdlet(cmdlet)
|
20
|
+
@cmdlet = cmdlet
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
# If you need to wrap the return value in a specific
|
@@ -20,5 +26,12 @@ module Handlebarsjs
|
|
20
26
|
def wrapper(value)
|
21
27
|
value
|
22
28
|
end
|
29
|
+
|
30
|
+
# Wrap the cmdlet call method in a handlebars context aware block
|
31
|
+
# and return as a lambda/proc so that it is available to the
|
32
|
+
# Handlebars template engine
|
33
|
+
def to_proc
|
34
|
+
->(value, _opts) { wrapper(cmdlet.call(value)) }
|
35
|
+
end
|
23
36
|
end
|
24
37
|
end
|
@@ -23,13 +23,10 @@ module Handlebarsjs
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def add_helper(name, helper)
|
26
|
-
callback
|
27
|
-
|
28
|
-
callback = helper.to_proc if callback.nil? && helper.respond_to?(:to_proc)
|
26
|
+
return add_helper_entry(name, callback: helper) if helper.is_a?(Proc)
|
27
|
+
return add_helper_entry(name, helper: helper, callback: helper.to_proc) if helper.respond_to?(:to_proc)
|
29
28
|
|
30
29
|
raise Handlebarsjs::Error, 'helper must be a callback or implement to_proc method' if callback.nil?
|
31
|
-
|
32
|
-
add_helper_callback(name, callback)
|
33
30
|
end
|
34
31
|
|
35
32
|
def register_helper(name)
|
@@ -76,9 +73,10 @@ module Handlebarsjs
|
|
76
73
|
add_script_item(name, type, script, path)
|
77
74
|
end
|
78
75
|
|
79
|
-
def
|
76
|
+
def add_helper_entry(name, helper: nil, callback: nil)
|
80
77
|
@helpers << {
|
81
78
|
name: name,
|
79
|
+
helper: helper,
|
82
80
|
callback: callback
|
83
81
|
}
|
84
82
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Array handling routines, eg. join, join_prefix, join_post
|
6
|
+
module Array
|
7
|
+
# Join: join an array of values with separator as a string
|
8
|
+
class Join < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Array::Join)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(values, separator = ',', _opts) { wrapper(cmdlet.call(values, separator)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Array handling routines, eg. join, join_prefix, join_post
|
6
|
+
module Array
|
7
|
+
# JoinPost: join an array of values with separator as a string and using the separator at the end of string
|
8
|
+
class JoinPost < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Array::JoinPost)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(values, separator = ',', _opts) { wrapper(cmdlet.call(values, separator)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Array handling routines, eg. join, join_prefix, join_post
|
6
|
+
module Array
|
7
|
+
# JoinPre: join an array of values with separator as a string and using the separator at the beginning of string
|
8
|
+
class JoinPre < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Array::JoinPre)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(values, separator = ',', _opts) { wrapper(cmdlet.call(values, separator)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Tokenize and apply case and/or separator
|
6
|
+
module Case
|
7
|
+
# BackSlash: Convert to back slash notation
|
8
|
+
class BackSlash < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Case::BackSlash)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(value, _opts) { wrapper(cmdlet.call(value)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Tokenize and apply case and/or separator
|
6
|
+
module Case
|
7
|
+
# Camel: Camel case the characters in the given 'string'
|
8
|
+
class Camel < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Case::Camel)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(value, _opts) { wrapper(cmdlet.call(value)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Tokenize and apply case and/or separator
|
6
|
+
module Case
|
7
|
+
# Constant: Constant case the characters in the given 'string'
|
8
|
+
class Constant < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Case::Constant)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(value, _opts) { wrapper(cmdlet.call(value)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Tokenize and apply case and/or separator
|
6
|
+
module Case
|
7
|
+
# Dash: Dash case the characters in the given 'string'
|
8
|
+
class Dash < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Case::Dash)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(value, _opts) { wrapper(cmdlet.call(value)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
module Helpers
|
5
|
+
# Tokenize and apply case and/or separator
|
6
|
+
module Case
|
7
|
+
# Dot: Dot case the characters in the given 'string'
|
8
|
+
class Dot < Handlebarsjs::BaseHelper
|
9
|
+
register_cmdlet(Cmdlet::Case::Dot)
|
10
|
+
|
11
|
+
def to_proc
|
12
|
+
->(value, _opts) { wrapper(cmdlet.call(value)) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|