summaryrefslogtreecommitdiffstats
path: root/modules/templates/static.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/templates/static.go')
-rw-r--r--modules/templates/static.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/modules/templates/static.go b/modules/templates/static.go
index f7e53ce887..435ccb1f95 100644
--- a/modules/templates/static.go
+++ b/modules/templates/static.go
@@ -14,6 +14,7 @@ import (
"io/ioutil"
"path"
"strings"
+ texttmpl "text/template"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -23,7 +24,8 @@ import (
)
var (
- templates = template.New("")
+ subjectTemplates = texttmpl.New("")
+ bodyTemplates = template.New("")
)
type templateFileSystem struct {
@@ -140,9 +142,12 @@ func JSRenderer() macaron.Handler {
}
// Mailer provides the templates required for sending notification mails.
-func Mailer() *template.Template {
+func Mailer() (*texttmpl.Template, *template.Template) {
+ for _, funcs := range NewTextFuncMap() {
+ subjectTemplates.Funcs(funcs)
+ }
for _, funcs := range NewFuncMap() {
- templates.Funcs(funcs)
+ bodyTemplates.Funcs(funcs)
}
for _, assetPath := range AssetNames() {
@@ -161,7 +166,8 @@ func Mailer() *template.Template {
continue
}
- templates.New(
+ buildSubjectBodyTemplate(subjectTemplates,
+ bodyTemplates,
strings.TrimPrefix(
strings.TrimSuffix(
assetPath,
@@ -169,7 +175,7 @@ func Mailer() *template.Template {
),
"mail/",
),
- ).Parse(string(content))
+ content)
}
customDir := path.Join(setting.CustomPath, "templates", "mail")
@@ -192,17 +198,18 @@ func Mailer() *template.Template {
continue
}
- templates.New(
+ buildSubjectBodyTemplate(subjectTemplates,
+ bodyTemplates,
strings.TrimSuffix(
filePath,
".tmpl",
),
- ).Parse(string(content))
+ content)
}
}
}
- return templates
+ return subjectTemplates, bodyTemplates
}
func Asset(name string) ([]byte, error) {