Refactor out the use of rice in favor of embed (#2)

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/spyda/pulls/2
This commit is contained in:
James Mills
2022-10-05 00:19:23 +00:00
parent 7001f3bf51
commit d4ab395515
13 changed files with 270 additions and 178 deletions

View File

@@ -0,0 +1,22 @@
package templates
import (
"embed"
"io/fs"
)
//go:embed *.html
var templates embed.FS
// MustGetTemplate returns a template string with the given name.
func MustGetTemplate(name string) string {
b, err := templates.ReadFile(name)
if err != nil {
panic(err)
}
return string(b)
}
func FS() fs.FS {
return templates
}