From 5d68bae54fc48854103dcc70ef236f8ae39f136b Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Thu, 29 Mar 2018 22:00:56 +0200 Subject: [PATCH] Use assets for mail templates --- notifications.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/notifications.go b/notifications.go index cf94898..25234ff 100644 --- a/notifications.go +++ b/notifications.go @@ -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 }