1
0
Fork 0
mirror of synced 2024-09-18 10:20:11 +12:00
budibase/packages/string-templates/src/helpers/Helper.js

20 lines
384 B
JavaScript
Raw Normal View History

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
2021-05-04 22:32:22 +12:00
handlebars.registerHelper(this.name, value => {
return this.fn(value) || value
})
}
unregister(handlebars) {
handlebars.unregisterHelper(this.name)
}
}
module.exports = Helper