package approve_former import ( "bytes" "github.com/pkg/errors" "text/template" ) type Noder interface { GetDepends() string GetWhen() string Render(upperNode Noder) (string, error) } func render(name string, templateStr string, templateParams map[string]any) (string, error) { tpl := template.New(name) tpl.Delims("[[", "]]") tpl, err := tpl.Parse(templateStr) if err != nil { return "", errors.New(err.Error()) } buffer := &bytes.Buffer{} err = tpl.Execute(buffer, templateParams) if err != nil { return "", errors.New(err.Error()) } return buffer.String(), nil }