Skip to content

Commit

Permalink
Add functions to notification templates (#1263)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbeaty committed Mar 26, 2023
1 parent d1d0922 commit a955102
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"syscall"
"time"

"github.com/Masterminds/sprig/v3"
"github.com/jmoiron/sqlx"
"github.com/jmoiron/sqlx/types"
"github.com/knadh/goyesql/v2"
Expand Down Expand Up @@ -602,6 +603,12 @@ func initNotifTemplates(path string, fs stuffbin.FileSystem, i *i18n.I18n, cs *c
"LogoURL": func() string {
return cs.LogoURL
},
"Date": func(layout string) string {
if layout == "" {
layout = time.ANSIC
}
return time.Now().Format(layout)
},
"L": func() *i18n.I18n {
return i
},
Expand All @@ -610,6 +617,10 @@ func initNotifTemplates(path string, fs stuffbin.FileSystem, i *i18n.I18n, cs *c
},
}

for k, v := range sprig.GenericFuncMap() {
funcs[k] = v
}

tpls, err := stuffbin.ParseTemplatesGlob(funcs, fs, "/static/email-templates/*.html")
if err != nil {
lo.Fatalf("error parsing e-mail notif templates: %v", err)
Expand Down

0 comments on commit a955102

Please sign in to comment.