1
0
Fork 0
mirror of synced 2024-07-01 20:41:03 +12:00

Fixing automations to use recurseMustache from utilities.

This commit is contained in:
mike12345567 2020-12-08 11:47:33 +00:00
parent b7f628e250
commit 9a63252666

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