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:
22
internal/templates/templates.go
Normal file
22
internal/templates/templates.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user