Skip to content

Commit

Permalink
Changed email subject template from HTML to text. Fixes #785.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed May 3, 2022
1 parent 75190d9 commit 89eca5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/manager/manager.go
Expand Up @@ -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
}

Expand Down
7 changes: 5 additions & 2 deletions models/models.go
Expand Up @@ -9,6 +9,7 @@ import (
"html/template"
"regexp"
"strings"
txttpl "text/template"
"time"

"github.com/jmoiron/sqlx"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 89eca5f

Please sign in to comment.