handlebarsjs 0.5.1 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/helper.rb +31 -0
  3. data/.builders/.templates/helper_spec.rb +38 -0
  4. data/.builders/_.rb +3 -1
  5. data/.builders/boot.rb +2 -2
  6. data/.builders/director/handlebars_helper_builder.rb +67 -0
  7. data/.builders/director/handlebars_helper_child.rb +67 -0
  8. data/.builders/director/handlebars_helper_director.rb +24 -0
  9. data/.builders/generators/helpers/comparison_helpers.rb +44 -0
  10. data/CHANGELOG.md +23 -0
  11. data/Gemfile +8 -0
  12. data/docs/domain_model.drawio +32 -32
  13. data/docs/domain_model.json +57 -57
  14. data/docs/project-plan/project.drawio +16 -16
  15. data/lib/_.rb +33 -0
  16. data/lib/handlebarsjs/base_helper.rb +18 -5
  17. data/lib/handlebarsjs/handlebars_snapshot.rb +4 -6
  18. data/lib/handlebarsjs/helpers/array/join.rb +17 -0
  19. data/lib/handlebarsjs/helpers/array/join_post.rb +17 -0
  20. data/lib/handlebarsjs/helpers/array/join_pre.rb +17 -0
  21. data/lib/handlebarsjs/helpers/case/back_slash.rb +17 -0
  22. data/lib/handlebarsjs/helpers/case/camel.rb +17 -0
  23. data/lib/handlebarsjs/helpers/case/constant.rb +17 -0
  24. data/lib/handlebarsjs/helpers/case/dash.rb +17 -0
  25. data/lib/handlebarsjs/helpers/case/dot.rb +17 -0
  26. data/lib/handlebarsjs/helpers/case/double_colon.rb +17 -0
  27. data/lib/handlebarsjs/helpers/case/human.rb +17 -0
  28. data/lib/handlebarsjs/helpers/case/lamel.rb +17 -0
  29. data/lib/handlebarsjs/helpers/case/lower.rb +17 -0
  30. data/lib/handlebarsjs/helpers/case/slash.rb +17 -0
  31. data/lib/handlebarsjs/helpers/case/snake.rb +17 -0
  32. data/lib/handlebarsjs/helpers/case/title.rb +17 -0
  33. data/lib/handlebarsjs/helpers/case/upper.rb +17 -0
  34. data/lib/handlebarsjs/helpers/comparison/and.rb +17 -0
  35. data/lib/handlebarsjs/helpers/comparison/default.rb +17 -0
  36. data/lib/handlebarsjs/helpers/comparison/eq.rb +17 -0
  37. data/lib/handlebarsjs/helpers/comparison/gt.rb +17 -0
  38. data/lib/handlebarsjs/helpers/comparison/gte.rb +17 -0
  39. data/lib/handlebarsjs/helpers/comparison/lt.rb +17 -0
  40. data/lib/handlebarsjs/helpers/comparison/lte.rb +17 -0
  41. data/lib/handlebarsjs/helpers/comparison/ne.rb +17 -0
  42. data/lib/handlebarsjs/helpers/comparison/or.rb +17 -0
  43. data/lib/handlebarsjs/helpers/inflection/ordinal.rb +17 -0
  44. data/lib/handlebarsjs/helpers/inflection/ordinalize.rb +17 -0
  45. data/lib/handlebarsjs/helpers/inflection/pluralize.rb +17 -0
  46. data/lib/handlebarsjs/helpers/inflection/pluralize_number.rb +17 -0
  47. data/lib/handlebarsjs/helpers/inflection/pluralize_number_word.rb +17 -0
  48. data/lib/handlebarsjs/helpers/inflection/singularize.rb +17 -0
  49. data/lib/handlebarsjs/version.rb +1 -1
  50. data/lib/handlebarsjs.rb +2 -0
  51. data/package-lock.json +2 -2
  52. data/package.json +1 -1
  53. metadata +57 -2
@@ -1,5 +1,5 @@
1
1
  {
2
- "host": "BiS",
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": "j0L",
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": "page_root_j0L",
62
- "parent_id": "j0L",
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": "node_root_j0L",
68
- "parent_id": "page_root_j0L",
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": "node_root_j0L",
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": "j0L-2",
87
- "parent_id": "node_root_j0L",
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": "j0L-3",
119
- "parent_id": "node_root_j0L",
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": "j0L-4",
151
- "parent_id": "node_root_j0L",
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": "j0L-5",
208
- "parent_id": "node_root_j0L",
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": "j0L-6",
230
- "parent_id": "node_root_j0L",
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": "j0L-7",
250
- "parent_id": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "node_root_j0L",
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": "j0L-17",
443
- "parent_id": "node_root_j0L",
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": "j0L-18",
463
- "parent_id": "node_root_j0L",
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": "j0L-19",
483
- "parent_id": "node_root_j0L",
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": "j0L-20",
503
- "parent_id": "node_root_j0L",
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": "j0L-21",
523
- "parent_id": "node_root_j0L",
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": "j0L-22",
543
- "parent_id": "node_root_j0L",
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": "j0L-23",
563
- "parent_id": "node_root_j0L",
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": "j0L-24",
583
- "parent_id": "node_root_j0L",
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": "j0L-25",
603
- "parent_id": "node_root_j0L",
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": "j0L-26",
623
- "parent_id": "node_root_j0L",
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": "j0L-27",
643
- "parent_id": "node_root_j0L",
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": "j0L-28",
663
- "parent_id": "node_root_j0L",
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": "node_root_j0L",
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": "j0L-30",
696
- "parent_id": "node_root_j0L",
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": "j0L-31",
716
- "parent_id": "node_root_j0L",
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="kOi">
2
- <diagram id="nkA" name="In progress">
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="page_root_nkA" parent="nkA"/>
6
- <mxCell id="node_root_nkA" parent="page_root_nkA"/>
7
- <mxCell id="nkA-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_nkA">
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="nkA-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_nkA">
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="nkA-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_nkA">
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="nkA-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_nkA">
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="nkA-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_nkA">
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="nkA-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_nkA">
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="kwv" name="To Do">
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="page_root_kwv" parent="kwv"/>
32
- <mxCell id="node_root_kwv" parent="page_root_kwv"/>
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="osb" name="Done">
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="page_root_osb" parent="osb"/>
40
- <mxCell id="node_root_osb" parent="page_root_osb"/>
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,33 @@
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_number'
32
+ require_relative 'handlebarsjs/helpers/inflection/pluralize_number_word'
33
+ require_relative 'handlebarsjs/helpers/inflection/singularize'
@@ -3,9 +3,22 @@
3
3
  module Handlebarsjs
4
4
  # Extend base helper for each of your custom handlebars-helpers
5
5
  class BaseHelper
6
- # All child classes will generally implement this method
7
- def parse(value)
8
- value
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
14
+ end
15
+
16
+ class << self
17
+ attr_reader :cmdlet
18
+
19
+ def register_cmdlet(cmdlet)
20
+ @cmdlet = cmdlet
21
+ end
9
22
  end
10
23
 
11
24
  # If you need to wrap the return value in a specific
@@ -14,11 +27,11 @@ module Handlebarsjs
14
27
  value
15
28
  end
16
29
 
17
- # Wrap the parse method in a handlebars context aware block
30
+ # Wrap the cmdlet call method in a handlebars context aware block
18
31
  # and return as a lambda/proc so that it is available to the
19
32
  # Handlebars template engine
20
33
  def to_proc
21
- ->(value, _opts) { wrapper(parse(value)) }
34
+ ->(value, _opts) { wrapper(cmdlet.call(value)) }
22
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 = nil
27
- callback = helper if helper.is_a?(Proc)
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 add_helper_callback(name, callback)
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 &#x27;string&#x27;
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 &#x27;string&#x27;
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 &#x27;string&#x27;
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 &#x27;string&#x27;
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