Files
accounting/pkg/invoice/report/qrbill/html.go

43 lines
698 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
//go:embed assets/style.css
var style template.CSS
type tmpler struct {
Invoice
Cross template.HTML
Scissors template.HTML
}
func (i Invoice) CSS() template.CSS {
return style
}
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
}