package assets import ( "embed" "net/http" "github.com/CloudyKit/jet/v6" ) //go:embed templates/*.jet var templatesFS embed.FS //go:embed static/* var staticFS embed.FS var Views *jet.Set func init() { loader := jet.NewInMemLoader() // Load templates from embed.FS templateFiles, err := templatesFS.ReadDir("templates") if err != nil { panic(err) } for _, tmpl := range templateFiles { if tmpl.IsDir() { continue } tmplPath := "templates/" + tmpl.Name() tmplContent, err := templatesFS.ReadFile(tmplPath) if err != nil { panic(err) } name := tmpl.Name() loader.Set(name, string(tmplContent)) } Views = jet.NewSet(loader) } func StaticHandler() http.Handler { return http.FileServer(http.FS(staticFS)) }