1 | 'use strict';
|
2 |
|
3 | var _ = require('lodash');
|
4 |
|
5 | function helper(paper) {
|
6 | paper.handlebars.registerHelper('pick', function () {
|
7 | return _.pick.apply(null, arguments);
|
8 | });
|
9 |
|
10 | |
11 |
|
12 |
|
13 | paper.handlebars.registerHelper('getShortMonth', function (index) {
|
14 |
|
15 | switch (index) {
|
16 | case 1:
|
17 | return 'Jan';
|
18 | case 2:
|
19 | return 'Feb';
|
20 | case 3:
|
21 | return 'Mar';
|
22 | case 4:
|
23 | return 'Apr';
|
24 | case 5:
|
25 | return 'May';
|
26 | case 6:
|
27 | return 'Jun';
|
28 | case 7:
|
29 | return 'Jul';
|
30 | case 8:
|
31 | return 'Aug';
|
32 | case 9:
|
33 | return 'Sep';
|
34 | case 10:
|
35 | return 'Oct';
|
36 | case 11:
|
37 | return 'Nov';
|
38 | case 12:
|
39 | return 'Dec';
|
40 | }
|
41 |
|
42 | return '';
|
43 | });
|
44 |
|
45 | |
46 |
|
47 |
|
48 | paper.handlebars.registerHelper('equals', function (val1, val2) {
|
49 | const options = arguments[arguments.length - 1];
|
50 |
|
51 | if (val1 != val2) {
|
52 | return '';
|
53 | }
|
54 |
|
55 | return options.fn();
|
56 | });
|
57 |
|
58 | |
59 |
|
60 |
|
61 | paper.handlebars.registerHelper('enumerate', function (start, end) {
|
62 | const options = arguments[arguments.length - 1];
|
63 | var out = '';
|
64 | var i = start;
|
65 |
|
66 | for (i; i <= end; i++) {
|
67 | out = out + options.fn(i);
|
68 | }
|
69 |
|
70 | return out + '';
|
71 | });
|
72 | }
|
73 |
|
74 | module.exports = helper;
|