mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 07:40:54 +00:00
fix #217
This commit is contained in:
parent
02c2e16253
commit
bed0fe2218
27
template.go
27
template.go
@ -160,6 +160,19 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
|
||||
t = template.New(file).Delims(TemplateLeft, TemplateRight).Funcs(beegoTplFuncMap)
|
||||
var submods [][]string
|
||||
t, submods, err = getTplDeep(root, file, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t, err = _getTemplate(t, root, submods, others...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func _getTemplate(t0 *template.Template, root string, submods [][]string, others ...string) (t *template.Template, err error) {
|
||||
t = t0
|
||||
for _, m := range submods {
|
||||
if len(m) == 2 {
|
||||
templ := t.Lookup(m[1])
|
||||
@ -169,9 +182,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
|
||||
//first check filename
|
||||
for _, otherfile := range others {
|
||||
if otherfile == m[1] {
|
||||
t, _, err = getTplDeep(root, otherfile, t)
|
||||
var submods1 [][]string
|
||||
t, submods1, err = getTplDeep(root, otherfile, t)
|
||||
if err != nil {
|
||||
Trace("template parse file err:", err)
|
||||
} else if submods1 != nil && len(submods1) > 0 {
|
||||
t, err = _getTemplate(t, root, submods1, others...)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -187,9 +203,12 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
|
||||
allsub := reg.FindAllStringSubmatch(string(data), -1)
|
||||
for _, sub := range allsub {
|
||||
if len(sub) == 2 && sub[1] == m[1] {
|
||||
t, _, err = getTplDeep(root, otherfile, t)
|
||||
var submods1 [][]string
|
||||
t, submods1, err = getTplDeep(root, otherfile, t)
|
||||
if err != nil {
|
||||
Trace("template parse file err:", err)
|
||||
} else if submods1 != nil && len(submods1) > 0 {
|
||||
t, err = _getTemplate(t, root, submods1, others...)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -198,9 +217,5 @@ func getTemplate(root, file string, others ...string) (t *template.Template, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user