@@ -42,18 +42,20 @@ func buildSubjectBodyTemplate(stpl *texttmpl.Template, btpl *template.Template,
42
42
subjectContent = content [0 :loc [0 ]]
43
43
bodyContent = content [loc [1 ]:]
44
44
}
45
- if _ , err := stpl .New (name ).
46
- Parse (string (subjectContent )); err != nil {
47
- log .Error ("Failed to parse template [%s/subject]: %v" , name , err )
48
- if ! setting .IsProd {
49
- log .Fatal ("Please fix the mail template error" )
45
+ if _ , err := stpl .New (name ).Parse (string (subjectContent )); err != nil {
46
+ // do not tolerate errors in production, but tolerate them in development (just like web templates)
47
+ if setting .IsProd {
48
+ log .Fatal ("Failed to parse template [%s/subject]: %v" , name , err )
49
+ } else {
50
+ log .Error ("Failed to parse template [%s/subject]: %v" , name , err )
50
51
}
51
52
}
52
- if _ , err := btpl .New (name ).
53
- Parse (string (bodyContent )); err != nil {
54
- log .Error ("Failed to parse template [%s/body]: %v" , name , err )
55
- if ! setting .IsProd {
56
- log .Fatal ("Please fix the mail template error" )
53
+ if _ , err := btpl .New (name ).Parse (string (bodyContent )); err != nil {
54
+ // do not tolerate errors in production, but tolerate them in development (just like web templates)
55
+ if setting .IsProd {
56
+ log .Fatal ("Failed to parse template [%s/body]: %v" , name , err )
57
+ } else {
58
+ log .Error ("Failed to parse template [%s/body]: %v" , name , err )
57
59
}
58
60
}
59
61
}
@@ -64,14 +66,7 @@ func Mailer(ctx context.Context) (*texttmpl.Template, *template.Template) {
64
66
bodyTemplates := template .New ("" )
65
67
66
68
subjectTemplates .Funcs (mailSubjectTextFuncMap ())
67
- // To do the best to avoid serious breaking, add some functions back for body templates.
68
- // Keep in mind that some behaviors have changed, for worse case, double-escaping.
69
- // Custom template users should migrate to the new template system ASAP.
70
- bodyTemplateFuncMap := NewFuncMap ()
71
- bodyTemplateFuncMap ["Safe" ] = SafeHTML
72
- bodyTemplateFuncMap ["Escape" ] = HTMLEscape
73
- bodyTemplateFuncMap ["Str2html" ] = SanitizeHTML
74
- bodyTemplates .Funcs (bodyTemplateFuncMap )
69
+ bodyTemplates .Funcs (NewFuncMap ())
75
70
76
71
assetFS := AssetFS ()
77
72
refreshTemplates := func (firstRun bool ) {
0 commit comments