ok tahts better render.go for template tests

master
Bel LaPointe 2022-02-14 08:39:58 -07:00
parent fd02626360
commit c21a6a5b3b
1 changed files with 3 additions and 2 deletions

View File

@ -39,13 +39,14 @@ func main() {
switch path.Ext(p) { switch path.Ext(p) {
case ".ctmpl": case ".ctmpl":
target := path.Join(path.Dir(p), "."+path.Base(p)+".html") target := path.Join(path.Dir(p), "."+path.Base(p)+".html")
defer log.Printf("rendering ...%s as %s", path.Join(path.Base(path.Dir(p)), path.Base(p)), target)
f, err := os.Create(path.Join(path.Dir(p), "."+path.Base(p)+".html")) f, err := os.Create(path.Join(path.Dir(p), "."+path.Base(p)+".html"))
if err != nil { if err != nil {
return err return err
} }
defer f.Close() defer f.Close()
return t(p).Execute(f, data) templateToExecute := strings.TrimSuffix(path.Base(p), path.Ext(p))
defer log.Printf("rendering %s (...%s) as %s", templateToExecute, path.Join(path.Base(path.Dir(p)), path.Base(p)), target)
return t(p).Lookup(templateToExecute).Execute(f, data)
} }
return nil return nil
}); err != nil { }); err != nil {