Fixing automations to use recurseMustache from utilities.
This commit is contained in:
parent
71fa39ef7e
commit
130f69caf5
|
@ -3,6 +3,7 @@ const actions = require("./actions")
|
|||
const logic = require("./logic")
|
||||
const automationUtils = require("./automationUtils")
|
||||
const AutomationEmitter = require("../events/AutomationEmitter")
|
||||
const { recurseMustache } = require("../utilities/mustache")
|
||||
|
||||
handlebars.registerHelper("object", value => {
|
||||
return new handlebars.SafeString(JSON.stringify(value))
|
||||
|
@ -10,22 +11,6 @@ handlebars.registerHelper("object", value => {
|
|||
|
||||
const FILTER_STEP_ID = logic.BUILTIN_DEFINITIONS.FILTER.stepId
|
||||
|
||||
function recurseMustache(inputs, context) {
|
||||
for (let key of Object.keys(inputs)) {
|
||||
let val = inputs[key]
|
||||
if (typeof val === "string") {
|
||||
val = automationUtils.cleanMustache(inputs[key])
|
||||
const template = handlebars.compile(val)
|
||||
inputs[key] = template(context)
|
||||
}
|
||||
// this covers objects and arrays
|
||||
else if (typeof val === "object") {
|
||||
inputs[key] = recurseMustache(inputs[key], context)
|
||||
}
|
||||
}
|
||||
return inputs
|
||||
}
|
||||
|
||||
/**
|
||||
* The automation orchestrator is a class responsible for executing automations.
|
||||
* It handles the context of the automation and makes sure each step gets the correct
|
||||
|
|
Loading…
Reference in New Issue