mirror of
https://github.com/thebaer/cdr.git
synced 2024-11-15 01:31:01 +00:00
Log parse and render errors
This commit is contained in:
parent
ac510fa586
commit
bcd4094f09
10
render.go
10
render.go
@ -6,6 +6,7 @@ import (
|
||||
"html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
func Render(m *Mixtape, w io.Writer) error {
|
||||
@ -15,15 +16,22 @@ func Render(m *Mixtape, w io.Writer) error {
|
||||
}
|
||||
mixtapeRawTmpl, err := ioutil.ReadFile("mixtape.tmpl")
|
||||
if err != nil {
|
||||
log.Print("Unable to load local mixtape.tmpl; falling back to default")
|
||||
mixtapeRawTmpl, err = ReadAsset("mixtape.tmpl", false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
log.Print("Generating from local mixtape.tmpl")
|
||||
}
|
||||
t, err := template.New("mixtape").Parse(string(mixtapeRawTmpl) + string(partsRawTmpl))
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Unable to parse: %v", err)
|
||||
return err
|
||||
}
|
||||
t.ExecuteTemplate(w, "mixtape", m)
|
||||
err = t.ExecuteTemplate(w, "mixtape", m)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Unable to render: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user