mirror of
https://github.com/pocketbase/pocketbase.git
synced 2024-12-01 11:01:04 +02:00
34 lines
676 B
Go
34 lines
676 B
Go
// Package mails implements various helper methods for sending user and admin
|
|
// emails like forgotten password, verification, etc.
|
|
package mails
|
|
|
|
import (
|
|
"bytes"
|
|
"text/template"
|
|
)
|
|
|
|
// resolveTemplateContent resolves inline html template strings.
|
|
func resolveTemplateContent(data any, content ...string) (string, error) {
|
|
if len(content) == 0 {
|
|
return "", nil
|
|
}
|
|
|
|
t := template.New("inline_template")
|
|
|
|
var parseErr error
|
|
for _, v := range content {
|
|
t, parseErr = t.Parse(v)
|
|
if parseErr != nil {
|
|
return "", parseErr
|
|
}
|
|
}
|
|
|
|
var wr bytes.Buffer
|
|
|
|
if executeErr := t.Execute(&wr, data); executeErr != nil {
|
|
return "", executeErr
|
|
}
|
|
|
|
return wr.String(), nil
|
|
}
|