UNPKG

927 BJavaScriptView Raw
1(function() {
2 var dir, fs, path;
3
4 fs = require('fs');
5
6 path = require('path');
7
8 dir = path.join(__dirname, 'helpers');
9
10 module.exports.register = function(Handlebars, options) {
11 var endsWith, file, loadFile, _i, _len, _ref, _results;
12
13 endsWith = function(str, search) {
14 var result;
15
16 result = str.indexOf(search, str.length - search.length);
17 return result !== -1;
18 };
19 loadFile = function(file) {
20 var helper;
21
22 if (!endsWith(file, 'helpers.js')) {
23 helper = require(file);
24 }
25 if (!(typeof helper === 'undefined' || typeof helper.register === 'undefined')) {
26 return helper.register(Handlebars, options);
27 }
28 };
29 _ref = fs.readdirSync(dir);
30 _results = [];
31 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
32 file = _ref[_i];
33 _results.push(loadFile(path.join(dir, file)));
34 }
35 return _results;
36 };
37
38}).call(this);