Add functions to notification templates (#1263)
This commit is contained in:
parent
d1d0922a8c
commit
a95510260d
1 changed files with 11 additions and 0 deletions
11
cmd/init.go
11
cmd/init.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/sprig/v3"
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/jmoiron/sqlx/types"
|
"github.com/jmoiron/sqlx/types"
|
||||||
"github.com/knadh/goyesql/v2"
|
"github.com/knadh/goyesql/v2"
|
||||||
|
@ -602,6 +603,12 @@ func initNotifTemplates(path string, fs stuffbin.FileSystem, i *i18n.I18n, cs *c
|
||||||
"LogoURL": func() string {
|
"LogoURL": func() string {
|
||||||
return cs.LogoURL
|
return cs.LogoURL
|
||||||
},
|
},
|
||||||
|
"Date": func(layout string) string {
|
||||||
|
if layout == "" {
|
||||||
|
layout = time.ANSIC
|
||||||
|
}
|
||||||
|
return time.Now().Format(layout)
|
||||||
|
},
|
||||||
"L": func() *i18n.I18n {
|
"L": func() *i18n.I18n {
|
||||||
return i
|
return i
|
||||||
},
|
},
|
||||||
|
@ -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")
|
tpls, err := stuffbin.ParseTemplatesGlob(funcs, fs, "/static/email-templates/*.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lo.Fatalf("error parsing e-mail notif templates: %v", err)
|
lo.Fatalf("error parsing e-mail notif templates: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue