Use assets for mail templates
This commit is contained in:
parent
94dcb5bd75
commit
5d68bae54f
1 changed files with 6 additions and 2 deletions
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"git.cacert.org/cacert-boardvoting/boardvoting"
|
||||
"github.com/Masterminds/sprig"
|
||||
"gopkg.in/gomail.v2"
|
||||
"text/template"
|
||||
|
@ -68,8 +69,11 @@ func MailNotifier(quitMailNotifier chan int) {
|
|||
}
|
||||
|
||||
func buildMail(templateName string, context interface{}) (mailText *bytes.Buffer, err error) {
|
||||
t, err := template.New(templateName).Funcs(
|
||||
sprig.GenericFuncMap()).ParseFiles(fmt.Sprintf("templates/%s", templateName))
|
||||
b, err := boardvoting.Asset(fmt.Sprintf("templates/%s", templateName))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
t, err := template.New(templateName).Funcs(sprig.GenericFuncMap()).Parse(string(b))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue