1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 23:31:29 +00:00

Refactor template

This commit is contained in:
miraclesu 2013-08-01 11:57:29 +08:00
parent 5ccdaeb09e
commit 6fbdbaae80

View File

@ -51,19 +51,13 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
if f == nil { if f == nil {
return err return err
} }
if f.IsDir() { if f.IsDir() || (f.Mode()&os.ModeSymlink) > 0 {
return nil return nil
} else if (f.Mode() & os.ModeSymlink) > 0 { }
if !HasTemplateEXt(paths) {
return nil return nil
} else {
hasExt := false
for _, v := range BeeTemplateExt {
if strings.HasSuffix(paths, v) {
hasExt = true
break
} }
}
if hasExt {
replace := strings.NewReplacer("\\", "/") replace := strings.NewReplacer("\\", "/")
a := []byte(paths) a := []byte(paths)
a = a[len([]byte(self.root)):] a = a[len([]byte(self.root)):]
@ -76,11 +70,18 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
self.files[subdir] = m self.files[subdir] = m
} }
}
}
return nil return nil
} }
func HasTemplateEXt(paths string) bool {
for _, v := range BeeTemplateExt {
if strings.HasSuffix(paths, "."+v) {
return true
}
}
return false
}
func AddTemplateExt(ext string) { func AddTemplateExt(ext string) {
for _, v := range BeeTemplateExt { for _, v := range BeeTemplateExt {
if v == ext { if v == ext {