pagr

A 'static site generator', built using dati.
Log | Files | Refs | Atom

commit e1806d3ae4aed856f406590c65a642eecec8d2ee
parent fc5a5c39878b1ff45aed3e25874c5c4b3b1de8a5
Author: gearsix <gearsix@tuta.io>
Date:   Sat, 27 Nov 2021 15:30:11 +0000

LoadTemplateDir ignores unknown file extensions

Diffstat:
Mtemplate.go | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/template.go b/template.go @@ -19,7 +19,8 @@ func LoadTemplateDir(dir string) (templates []suti.Template, err error) { templatePaths := make(map[string][]string) // map[rootPath][]partialPaths... err = filepath.Walk(dir, func(path string, info fs.FileInfo, e error) error { - if e != nil || info.IsDir() || strings.Contains(path, ".ignore") { + lang := strings.TrimPrefix(filepath.Ext(path), ".") + if e != nil || info.IsDir() || strings.Contains(path, ".ignore") || suti.IsSupportedTemplateLang(lang) == -1 { return e } @@ -28,7 +29,8 @@ func LoadTemplateDir(dir string) (templates []suti.Template, err error) { }) err = filepath.Walk(dir, func(path string, info fs.FileInfo, e error) error { - if e != nil || info.IsDir() || ignoreFile(path) { + lang := strings.TrimPrefix(filepath.Ext(path), ".") + if e != nil || info.IsDir() || ignoreFile(path) || suti.IsSupportedTemplateLang(lang) == -1 { return e }