1
0
Fork 0
mirror of synced 2024-09-18 02:08:34 +12:00
budibase/packages/string-templates/src/helpers/Helper.js
2021-05-04 11:32:22 +01:00

19 lines
384 B
JavaScript

class Helper {
constructor(name, fn) {
this.name = name
this.fn = fn
}
register(handlebars) {
// wrap the function so that no helper can cause handlebars to break
handlebars.registerHelper(this.name, value => {
return this.fn(value) || value
})
}
unregister(handlebars) {
handlebars.unregisterHelper(this.name)
}
}
module.exports = Helper