messages: switch to new template package

rewrote and put in its own repo. Now supports {if a ==/!= b}, string
literals ({if a == "b"}), else/else if and nested if statements.
This commit is contained in:
Harvey Tindall
2025-12-04 11:50:14 +00:00
parent 6e31a7e2dd
commit b59cd73e43
7 changed files with 15 additions and 285 deletions
+4 -2
View File
@@ -19,6 +19,8 @@ import (
textTemplate "text/template"
"time"
sTemplate "github.com/hrfee/simple-template"
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
"github.com/hrfee/jfa-go/easyproxy"
@@ -251,13 +253,13 @@ func (emailer *Emailer) construct(contentInfo CustomContentInfo, cc CustomConten
Subject: contentInfo.Subject(emailer.config, &emailer.lang),
}
// Template the subject for bonus points
if subject, err := templateEmail(msg.Subject, contentInfo.Variables, contentInfo.Conditionals, data); err == nil {
if subject, err := sTemplate.Template(msg.Subject, data); err == nil {
msg.Subject = subject
}
if cc.Enabled {
// Use template email, rather than the built-in's email file.
contentInfo.SourceFile = customContent["TemplateEmail"].SourceFile
content, err := templateEmail(cc.Content, contentInfo.Variables, contentInfo.Conditionals, data)
content, err := sTemplate.Template(cc.Content, data)
if err != nil {
emailer.err.Printf(lm.FailedConstructCustomContent, msg.Subject, err)
return msg, err