mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:01:31 +00:00
Refactor template
This commit is contained in:
parent
5ccdaeb09e
commit
6fbdbaae80
25
template.go
25
template.go
@ -51,19 +51,13 @@ func (self *templatefile) visit(paths string, f os.FileInfo, err error) error {
|
||||
if f == nil {
|
||||
return err
|
||||
}
|
||||
if f.IsDir() {
|
||||
if f.IsDir() || (f.Mode()&os.ModeSymlink) > 0 {
|
||||
return nil
|
||||
} else if (f.Mode() & os.ModeSymlink) > 0 {
|
||||
}
|
||||
if !HasTemplateEXt(paths) {
|
||||
return nil
|
||||
} else {
|
||||
hasExt := false
|
||||
for _, v := range BeeTemplateExt {
|
||||
if strings.HasSuffix(paths, v) {
|
||||
hasExt = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if hasExt {
|
||||
|
||||
replace := strings.NewReplacer("\\", "/")
|
||||
a := []byte(paths)
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func HasTemplateEXt(paths string) bool {
|
||||
for _, v := range BeeTemplateExt {
|
||||
if strings.HasSuffix(paths, "."+v) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func AddTemplateExt(ext string) {
|
||||
for _, v := range BeeTemplateExt {
|
||||
if v == ext {
|
||||
|
Loading…
Reference in New Issue
Block a user