1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package static
import (
"bytes"
_ "embed"
"html/template"
)
//go:embed "emailconfirm.html.tmpl"
var emailConfirmTemplate []byte
// GetEmailConfirmTemplate will return the email confirmation template.
func GetEmailConfirmTemplate() string {
return string(getFileSystemStaticFileOrDefault("emailconfirm.html.tmpl", emailConfirmTemplate))
}
// GetEmailConfirmTemplateWithContent will return the email confirmation
// template with content populated.
func GetEmailConfirmTemplateWithContent(title, subtitle, footer, button, buttonLink string) (string, error) {
type content struct {
Title string
Subtitle string
SecondaryText string
Button string
ButtonLink string
ShowFooter bool
}
data := content{
Title: title,
Subtitle: subtitle,
SecondaryText: footer,
Button: button,
ButtonLink: buttonLink,
ShowFooter: false,
}
templateBytes := GetEmailConfirmTemplate()
t, err := template.New("emailConfirm").Parse(templateBytes)
if err != nil {
return "", err
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, data); err != nil {
return "", err
}
return tpl.String(), nil
}
|