1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 16:30:55 +00:00

Merge pull request #2574 from extrlibs/master

Fix the following template reference
This commit is contained in:
astaxie 2017-04-19 21:18:26 +08:00 committed by GitHub
commit d3f3956def

View File

@ -230,9 +230,12 @@ func BuildTemplate(dir string, files ...string) error {
func getTplDeep(root, file, parent string, t *template.Template) (*template.Template, [][]string, error) { func getTplDeep(root, file, parent string, t *template.Template) (*template.Template, [][]string, error) {
var fileAbsPath string var fileAbsPath string
var rParent string
if filepath.HasPrefix(file, "../") { if filepath.HasPrefix(file, "../") {
rParent = filepath.Join(filepath.Dir(parent), file)
fileAbsPath = filepath.Join(root, filepath.Dir(parent), file) fileAbsPath = filepath.Join(root, filepath.Dir(parent), file)
} else { } else {
rParent = file
fileAbsPath = filepath.Join(root, file) fileAbsPath = filepath.Join(root, file)
} }
if e := utils.FileExists(fileAbsPath); !e { if e := utils.FileExists(fileAbsPath); !e {
@ -257,7 +260,7 @@ func getTplDeep(root, file, parent string, t *template.Template) (*template.Temp
if !HasTemplateExt(m[1]) { if !HasTemplateExt(m[1]) {
continue continue
} }
_, _, err = getTplDeep(root, m[1], file, t) _, _, err = getTplDeep(root, m[1], rParent, t)
if err != nil { if err != nil {
return nil, [][]string{}, err return nil, [][]string{}, err
} }