Fixing automations to use recurseMustache from utilities.

This commit is contained in:
mike12345567 2020-12-08 11:47:33 +00:00
parent 71fa39ef7e
commit 130f69caf5
1 changed files with 1 additions and 16 deletions

View File

@ -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