Use assets for mail templates
authorJan Dittberner <jandd@cacert.org>
Thu, 29 Mar 2018 20:00:56 +0000 (22:00 +0200)
committerJan Dittberner <jandd@cacert.org>
Thu, 29 Mar 2018 20:00:56 +0000 (22:00 +0200)
notifications.go

index cf94898..25234ff 100644 (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
        }