Merge pull request #12636 from Budibase/cache-get-helpers-list
Cache the helpers list for executing JS.
This commit is contained in:
commit
de3302600f
|
@ -1,19 +1,26 @@
|
||||||
const externalHandlebars = require("./external")
|
const externalHandlebars = require("./external")
|
||||||
const helperList = require("@budibase/handlebars-helpers")
|
const helperList = require("@budibase/handlebars-helpers")
|
||||||
|
|
||||||
|
let helpers = undefined
|
||||||
|
|
||||||
module.exports.getHelperList = () => {
|
module.exports.getHelperList = () => {
|
||||||
|
if (helpers) {
|
||||||
|
return helpers
|
||||||
|
}
|
||||||
|
|
||||||
|
helpers = {}
|
||||||
let constructed = []
|
let constructed = []
|
||||||
for (let collection of externalHandlebars.externalCollections) {
|
for (let collection of externalHandlebars.externalCollections) {
|
||||||
constructed.push(helperList[collection]())
|
constructed.push(helperList[collection]())
|
||||||
}
|
}
|
||||||
const fullMap = {}
|
|
||||||
for (let collection of constructed) {
|
for (let collection of constructed) {
|
||||||
for (let [key, func] of Object.entries(collection)) {
|
for (let [key, func] of Object.entries(collection)) {
|
||||||
fullMap[key] = func
|
helpers[key] = func
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let key of Object.keys(externalHandlebars.addedHelpers)) {
|
for (let key of Object.keys(externalHandlebars.addedHelpers)) {
|
||||||
fullMap[key] = externalHandlebars.addedHelpers[key]
|
helpers[key] = externalHandlebars.addedHelpers[key]
|
||||||
}
|
}
|
||||||
return fullMap
|
Object.freeze(helpers)
|
||||||
|
return helpers
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue