2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Template helper definitions for Handlebars.
|
2016-02-14 09:10:23 +00:00
|
|
|
@license MIT. See LICENSE.md for details.
|
2016-01-27 10:29:26 +00:00
|
|
|
@module handlebars-helpers.js
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
2016-02-14 09:10:23 +00:00
|
|
|
var HANDLEBARS, _, blockHelpers, helpers;
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
HANDLEBARS = require('handlebars');
|
|
|
|
|
|
|
|
_ = require('underscore');
|
|
|
|
|
|
|
|
helpers = require('./generic-helpers');
|
|
|
|
|
2016-02-14 09:10:23 +00:00
|
|
|
blockHelpers = require('./block-helpers');
|
|
|
|
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Register useful Handlebars helpers.
|
|
|
|
@method registerHelpers
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = function(theme, opts) {
|
2016-02-14 09:10:23 +00:00
|
|
|
var wrappedHelpers;
|
2016-01-27 10:29:26 +00:00
|
|
|
helpers.theme = theme;
|
|
|
|
helpers.opts = opts;
|
2016-02-14 09:10:23 +00:00
|
|
|
helpers.type = 'handlebars';
|
|
|
|
wrappedHelpers = _.mapObject(helpers, function(hVal, hKey) {
|
|
|
|
if (_.isFunction(hVal)) {
|
|
|
|
_.wrap(hVal, function(func) {
|
|
|
|
var args;
|
|
|
|
args = Array.prototype.slice.call(arguments);
|
|
|
|
args.shift();
|
|
|
|
args.pop();
|
|
|
|
return func.apply(this, args);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return hVal;
|
|
|
|
}, this);
|
|
|
|
HANDLEBARS.registerHelper(wrappedHelpers);
|
|
|
|
HANDLEBARS.registerHelper(blockHelpers);
|
2016-01-27 10:29:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}).call(this);
|
2016-02-02 02:14:36 +00:00
|
|
|
|
|
|
|
//# sourceMappingURL=handlebars-helpers.js.map
|