Better checking for EKSTER_TEMPLATES

This commit is contained in:
Peter Stuifzand 2018-07-12 21:04:26 +02:00
parent 4c59931283
commit bc180ca8b3

View File

@ -80,8 +80,14 @@ type settingsPage struct {
func newMainHandler(backend *memoryBackend) (*mainHandler, error) {
h := &mainHandler{Backend: backend}
templates, err := template.ParseGlob("*.html")
templateDir := os.Getenv("EKSTER_TEMPLATES")
if templateDir == "" {
return nil, fmt.Errorf("Missing env var EKSTER_TEMPLATES")
}
templateDir = strings.TrimRight(templateDir, "/")
templates, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templateDir))
if err != nil {
return nil, err
}