mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:20:54 +00:00
fix(Template): remove duplicate check open/exists
This commit is contained in:
parent
7aae58a543
commit
f740b71ded
@ -186,16 +186,13 @@ func BuildTemplate(dir string, files ...string) error {
|
|||||||
fs := beeTemplateFS()
|
fs := beeTemplateFS()
|
||||||
f, err := fs.Open(dir)
|
f, err := fs.Open(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("dir open err")
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
if _, err := f.Stat(); err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.New("dir open err")
|
return errors.New("dir open err")
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
beeTemplates, ok := beeViewPathTemplates[dir]
|
beeTemplates, ok := beeViewPathTemplates[dir]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("Unknown view path: " + dir)
|
panic("Unknown view path: " + dir)
|
||||||
|
@ -105,7 +105,7 @@ var user = `<!DOCTYPE html>
|
|||||||
|
|
||||||
func TestRelativeTemplate(t *testing.T) {
|
func TestRelativeTemplate(t *testing.T) {
|
||||||
dir := "_beeTmp"
|
dir := "_beeTmp"
|
||||||
os.Mkdir(dir, 0777)
|
|
||||||
//Just add dir to known viewPaths
|
//Just add dir to known viewPaths
|
||||||
if err := AddViewPath(dir); err != nil {
|
if err := AddViewPath(dir); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user