feat: user templates
This commit was merged in pull request #9.
This commit is contained in:
@@ -9,15 +9,16 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
//go:embed assets/template.html
|
||||
var htmlTemplate string
|
||||
|
||||
//go:embed assets/style.css
|
||||
var style template.CSS
|
||||
|
||||
//go:embed assets/tailwind.js
|
||||
var tailwind template.JS
|
||||
|
||||
type tmpler struct {
|
||||
Report
|
||||
Style template.CSS
|
||||
Tailwind template.JS
|
||||
Style template.CSS
|
||||
}
|
||||
|
||||
func (r Report) ToHTML() (html string, err error) {
|
||||
@@ -29,11 +30,11 @@ func (r Report) ToHTML() (html string, err error) {
|
||||
"time": fmtDateTime,
|
||||
"date": fmtDate,
|
||||
"duration": fmtDuration,
|
||||
}).Parse(htmlTemplate))
|
||||
}).Parse(r.template))
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
err = tmpl.Execute(buf, tmpler{r, style})
|
||||
err = tmpl.Execute(buf, tmpler{r, tailwind, style})
|
||||
if err != nil {
|
||||
return html, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user