Use assets for mail templates

This commit is contained in:
Jan Dittberner 2018-03-29 22:00:56 +02:00
parent 94dcb5bd75
commit 5d68bae54f

View file

@ -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
}