修复模板注入问题
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
sprig "github.com/go-task/slim-sprig/v3"
|
||||
"net/http"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
func NewTemplateInject(r *http.Request, def map[string]any) map[string]any {
|
||||
@@ -23,3 +25,7 @@ func NewTemplateInject(r *http.Request, def map[string]any) map[string]any {
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func NewTemplate(data string) *template.Template {
|
||||
return template.Must(template.New("err").Funcs(sprig.FuncMap()).Parse(data))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user