From 5f4fe6d8683d1ce4e8291783833f7e3311d70737 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 29 Oct 2013 23:05:48 +0800 Subject: [PATCH] fix #260 --- template.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/template.go b/template.go index 15bc35d9..904ce6b3 100644 --- a/template.go +++ b/template.go @@ -154,10 +154,23 @@ func getTplDeep(root, file string, t *template.Template) (*template.Template, [] if !HasTemplateEXt(m[1]) { continue } - t, _, err = getTplDeep(root, m[1], t) - if err != nil { - return nil, [][]string{}, err + if e, _ := FileExists(filepath.Join(root, m[1])); e { + t, _, err = getTplDeep(root, m[1], t) + if err != nil { + return nil, [][]string{}, err + } + } else { + relativefile := filepath.Join(filepath.Dir(file), m[1]) + if e, _ := FileExists(relativefile); e { + t, _, err = getTplDeep(root, m[1], t) + if err != nil { + return nil, [][]string{}, err + } + } else { + panic("can't find template file" + m[1]) + } } + } } return t, allsub, nil