mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +08:00
Merge 78e74dc158323fe33b95b3a506b1acf670bfc180 into 8763f33c65f7df8be5b9fe7504ab7fcf20abb41d
This commit is contained in:
commit
a075c2a8bd
8
gin.go
8
gin.go
@ -259,10 +259,14 @@ func (engine *Engine) SecureJsonPrefix(prefix string) *Engine {
|
||||
|
||||
// LoadHTMLGlob loads HTML files identified by glob pattern
|
||||
// and associates the result with HTML renderer.
|
||||
func (engine *Engine) LoadHTMLGlob(pattern string) {
|
||||
func (engine *Engine) LoadHTMLGlob(pattern ...string) {
|
||||
left := engine.delims.Left
|
||||
right := engine.delims.Right
|
||||
templ := template.Must(template.New("").Delims(left, right).Funcs(engine.FuncMap).ParseGlob(pattern))
|
||||
|
||||
templ := template.New("").Delims(left, right).Funcs(engine.FuncMap)
|
||||
for _, p := range pattern {
|
||||
templ = template.Must(templ.ParseGlob(p))
|
||||
}
|
||||
|
||||
if IsDebugging() {
|
||||
debugPrintLoadTemplate(templ)
|
||||
|
@ -32,7 +32,7 @@ type HTMLProduction struct {
|
||||
// HTMLDebug contains template delims and pattern and function with file list.
|
||||
type HTMLDebug struct {
|
||||
Files []string
|
||||
Glob string
|
||||
Glob []string
|
||||
Delims Delims
|
||||
FuncMap template.FuncMap
|
||||
}
|
||||
@ -70,8 +70,11 @@ func (r HTMLDebug) loadTemplate() *template.Template {
|
||||
if len(r.Files) > 0 {
|
||||
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseFiles(r.Files...))
|
||||
}
|
||||
if r.Glob != "" {
|
||||
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseGlob(r.Glob))
|
||||
if len(r.Glob) > 0 {
|
||||
tmpl := template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap)
|
||||
for _, g := range r.Glob {
|
||||
tmpl = template.Must(tmpl.ParseGlob(g))
|
||||
}
|
||||
}
|
||||
panic("the HTML debug render was created without files or glob pattern")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user