1
0
mirror of https://github.com/thebaer/cdr.git synced 2024-11-15 01:31:01 +00:00
cdr/render.go
Matt Baer f0aa182c03 Add cdr preview subcommand
This serves the mixtape site by running `cdr preview`
2020-02-26 00:13:51 -05:00

27 lines
528 B
Go

//go:generate inline -o templates.go -p cdr templates/parts.tmpl
package cdr
import (
"html/template"
"io"
"io/ioutil"
)
func Render(m *Mixtape, w io.Writer) error {
partsRawTmpl, err := ReadAsset("templates/parts.tmpl", false)
if err != nil {
return err
}
mixtapeRawTmpl, err := ioutil.ReadFile("mixtape.tmpl")
if err != nil {
return err
}
t, err := template.New("mixtape").Parse(string(mixtapeRawTmpl) + string(partsRawTmpl))
if err != nil {
return err
}
t.ExecuteTemplate(w, "mixtape", m)
return nil
}