first commit
This commit is contained in:
18
internal/messages/render.go
Normal file
18
internal/messages/render.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package messages
|
||||
|
||||
import "strings"
|
||||
|
||||
func (t *Templates) Render(eventType string, vars map[string]string) (string, error) {
|
||||
tmpl, err := t.Get(eventType)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if tmpl == "" {
|
||||
return "", nil
|
||||
}
|
||||
out := tmpl
|
||||
for k, v := range vars {
|
||||
out = strings.ReplaceAll(out, "{"+k+"}", v)
|
||||
}
|
||||
return strings.TrimSpace(out), nil
|
||||
}
|
||||
Reference in New Issue
Block a user