lavender/server/pages/pages.go

29 lines
491 B
Go
Raw Normal View History

2023-10-08 15:24:59 +01:00
package pages
import (
"embed"
_ "embed"
"github.com/1f349/overlapfs"
2023-10-08 15:24:59 +01:00
"html/template"
"os"
"path/filepath"
2023-10-08 15:24:59 +01:00
)
var (
//go:embed *.go.html
2023-10-08 15:24:59 +01:00
flowPages embed.FS
FlowTemplates *template.Template
2023-10-08 15:24:59 +01:00
)
func LoadPages(wd string) error {
wwwDir := filepath.Join(wd, "www")
err := os.Mkdir(wwwDir, os.ModePerm)
if err != nil {
return nil
}
wdFs := os.DirFS(wwwDir)
o := overlapfs.OverlapFS{A: flowPages, B: wdFs}
FlowTemplates, err = template.ParseFS(o, "*.go.html")
return err
2023-10-08 15:24:59 +01:00
}