ok tahts better render.go for template tests
parent
fd02626360
commit
c21a6a5b3b
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue