All checks were successful
Go / build (push) Successful in 14s
feat: user templates
36 lines
591 B
Go
36 lines
591 B
Go
package qrbill
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
|
|
_ "embed"
|
|
)
|
|
|
|
//go:embed assets/ch-cross.svg
|
|
var chCross template.HTML
|
|
|
|
//go:embed assets/scissors.svg
|
|
var scissors template.HTML
|
|
|
|
//go:embed assets/template.html
|
|
var htmlTemplate string
|
|
|
|
type tmpler struct {
|
|
Invoice
|
|
Cross template.HTML
|
|
Scissors template.HTML
|
|
}
|
|
|
|
func (i Invoice) HTML() (html template.HTML, err error) {
|
|
tmpl := template.Must(template.New("invoice").Parse(htmlTemplate))
|
|
|
|
data := tmpler{i, chCross, scissors}
|
|
|
|
buf := new(bytes.Buffer)
|
|
err = tmpl.Execute(buf, data)
|
|
html = template.HTML(buf.String())
|
|
|
|
return
|
|
}
|