Skip to content

Commit

Permalink
Refactor template
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclesu committed Aug 1, 2013
1 parent 5ccdaeb commit 6fbdbaa
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,35 @@ 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
}

replace := strings.NewReplacer("\\", "/")
a := []byte(paths)
a = a[len([]byte(self.root)):]
subdir := path.Dir(strings.TrimLeft(replace.Replace(string(a)), "/"))
if _, ok := self.files[subdir]; ok {
self.files[subdir] = append(self.files[subdir], paths)
} 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)):]
subdir := path.Dir(strings.TrimLeft(replace.Replace(string(a)), "/"))
if _, ok := self.files[subdir]; ok {
self.files[subdir] = append(self.files[subdir], paths)
} else {
m := make([]string, 1)
m[0] = paths
self.files[subdir] = m
}
m := make([]string, 1)
m[0] = paths
self.files[subdir] = m
}

return nil
}

func HasTemplateEXt(paths string) bool {
for _, v := range BeeTemplateExt {
if strings.HasSuffix(paths, "."+v) {
return true
}
}
return nil
return false
}

func AddTemplateExt(ext string) {
Expand Down

0 comments on commit 6fbdbaa

Please sign in to comment.