Files
handlebars.js/lib/handlebars/internal/wrapHelper.js
T
Jakob Linskeseder c18ed16f71 Update repository URL
Related to c295ef085f.
2021-12-30 00:47:47 +01:00

14 lines
577 B
JavaScript

export function wrapHelper(helper, transformOptionsFn) {
if (typeof helper !== 'function') {
// This should not happen, but apparently it does in https://github.com/handlebars-lang/handlebars.js/issues/1639
// We try to make the wrapper least-invasive by not wrapping it, if the helper is not a function.
return helper;
}
let wrapper = function(/* dynamic arguments */) {
const options = arguments[arguments.length - 1];
arguments[arguments.length - 1] = transformOptionsFn(options);
return helper.apply(this, arguments);
};
return wrapper;
}