(template *template.Template, parts []string, params map[string]any)
| 79 | } |
| 80 | |
| 81 | func ExecuteTemplate(template *template.Template, parts []string, params map[string]any) (map[string]string, error) { |
| 82 | content := map[string]string{} |
| 83 | buffer := new(bytes.Buffer) |
| 84 | |
| 85 | if parts == nil { |
| 86 | if err := template.Execute(buffer, params); err != nil { |
| 87 | return nil, err |
| 88 | } |
| 89 | content[""] = buffer.String() |
| 90 | } else { |
| 91 | for _, part := range parts { |
| 92 | buffer.Reset() |
| 93 | if templBody := template.Lookup(part); templBody != nil { |
| 94 | if err := templBody.Execute(buffer, params); err != nil { |
| 95 | return nil, err |
| 96 | } |
| 97 | } |
| 98 | content[part] = buffer.String() |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return content, nil |
| 103 | } |
| 104 | |
| 105 | func ResolveTemplatePath(path string) (string, error) { |
| 106 | if filepath.IsAbs(path) { |
no test coverage detected
searching dependent graphs…