// renders the task level variables with global vars func (task Task) RenderVars(varsMap VarsMap, registerMap map[string]interface{}) error { ctxt := pongo2.Context{"vars": varsMap} ctxt = ctxt.Update(registerMap) if err := renderVarsHelper(task.Vars, ctxt); err != nil { return err } return nil }
// strings will be evaluated using pongo2 templating with context of // VarsMap and RegisterMap func renderValue(value string, varsMap VarsMap, registerMap map[string]interface{}) (string, error) { tmpl, err := pongo2.FromString(value) if err != nil { return "", HenchErr(err, map[string]interface{}{ "value": value, "solution": "Refer to wiki for proper pongo2 formatting", }, "While templating") } ctxt := pongo2.Context{"vars": varsMap} ctxt = ctxt.Update(registerMap) out, err := tmpl.Execute(ctxt) if err != nil { return "", HenchErr(err, map[string]interface{}{ "value": value, "context": ctxt, "solution": "Refer to wiki for proper pongo2 formatting", }, "While executing") } return out, nil }