gocustomurls/embed.go

31 lines
574 B
Go
Raw Normal View History

2024-05-06 07:20:30 +00:00
package main
import (
"embed"
"html/template"
)
2024-05-28 23:30:59 +00:00
// https://stackoverflow.com/questions/70193820/why-isnt-go-embedding-files
//
//go:embed templates/*
2024-05-06 07:20:30 +00:00
var tmpls embed.FS
2024-05-28 23:30:59 +00:00
func GetServeHtml() (*template.Template, error) {
var t *template.Template
data, err := tmpls.ReadFile("templates/success.html")
if err != nil {
return t, err
}
return template.New("").Parse(string(data))
2024-05-06 07:20:30 +00:00
}
2024-05-28 23:30:59 +00:00
func GetDefaultHtml() ([]byte, error) {
var data []byte
var err error
data, err = tmpls.ReadFile("templates/default.html")
if err != nil {
return data, err
}
return data, nil
2024-05-06 07:20:30 +00:00
}