Execute executes the template and returns the subject, body, and any error
(name, kind string, data any)
| 119 | |
| 120 | // Execute executes the template and returns the subject, body, and any error |
| 121 | func (tmpl Templates) Execute(name, kind string, data any) (subject, body string, err error) { |
| 122 | t, err := tmpl.get(name, kind) |
| 123 | if err != nil { |
| 124 | return "", "", errors.Wrap(err, "getting template") |
| 125 | } |
| 126 | |
| 127 | buf := new(bytes.Buffer) |
| 128 | if err := t.tmpl.Execute(buf, data); err != nil { |
| 129 | return "", "", errors.Wrap(err, "executing the template") |
| 130 | } |
| 131 | |
| 132 | return t.subject, buf.String(), nil |
| 133 | } |