-
-
Notifications
You must be signed in to change notification settings - Fork 364
/
index.js
61 lines (50 loc) · 1.26 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*!
* handlebars-helpers <https://github.com/helpers/handlebars-helpers>
*
* Copyright (c) 2013-2017, Jon Schlinkert, Brian Woodward.
* Released under the MIT License.
*/
'use strict';
var forIn = require('for-in');
var define = require('define-property');
var lib = require('./lib/');
/**
* Expose helpers
*/
module.exports = function helpers(groups, options) {
if (typeof groups === 'string') {
groups = [groups];
} else if (!Array.isArray(groups)) {
options = groups;
groups = null;
}
options = options || {};
var hbs = options.handlebars || options.hbs || require('handlebars');
define(module.exports, 'handlebars', hbs);
if (groups) {
groups.forEach(function(key) {
hbs.registerHelper(lib[key]);
});
} else {
forIn(lib, function(group, key) {
hbs.registerHelper(group);
});
}
return hbs.helpers;
};
/**
* Expose helper groups
*/
forIn(lib, function(group, key) {
define(module.exports, key, function(options) {
options = options || {};
var hbs = options.handlebars || options.hbs || require('handlebars');
define(module.exports, 'handlebars', hbs);
hbs.registerHelper(group);
return hbs.helpers;
});
});
/**
* Expose `utils`
*/
module.exports.utils = require('./lib/utils');