From 89eca5f14bdc145e2baca994261de67434628bdf Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Tue, 3 May 2022 10:41:46 +0530 Subject: [PATCH] Changed email subject template from HTML to text. Fixes #785. --- internal/manager/manager.go | 2 ++ models/models.go | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/manager/manager.go b/internal/manager/manager.go index 3bebea9..aef8333 100644 --- a/internal/manager/manager.go +++ b/internal/manager/manager.go @@ -436,9 +436,11 @@ func (m *Manager) TemplateFuncs(c *models.Campaign) template.FuncMap { return template.HTML(safeHTML) }, } + for k, v := range sprig.GenericFuncMap() { f[k] = v } + return f } diff --git a/models/models.go b/models/models.go index 2b07b81..ea22755 100644 --- a/models/models.go +++ b/models/models.go @@ -9,6 +9,7 @@ import ( "html/template" "regexp" "strings" + txttpl "text/template" "time" "github.com/jmoiron/sqlx" @@ -218,7 +219,7 @@ type Campaign struct { // TemplateBody is joined in from templates by the next-campaigns query. TemplateBody string `db:"template_body" json:"-"` Tpl *template.Template `json:"-"` - SubjectTpl *template.Template `json:"-"` + SubjectTpl *txttpl.Template `json:"-"` AltBodyTpl *template.Template `json:"-"` // Pseudofield for getting the total number of subscribers @@ -436,7 +437,9 @@ func (c *Campaign) CompileTemplate(f template.FuncMap) error { for _, r := range regTplFuncs { subj = r.regExp.ReplaceAllString(subj, r.replace) } - subjTpl, err := template.New(ContentTpl).Funcs(f).Parse(subj) + + var txtFuncs map[string]interface{} = f + subjTpl, err := txttpl.New(ContentTpl).Funcs(txtFuncs).Parse(subj) if err != nil { return fmt.Errorf("error compiling subject: %v", err) }