diff options
Diffstat (limited to 'internal/server/templates.go')
-rw-r--r-- | internal/server/templates.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/server/templates.go b/internal/server/templates.go index d8ffcf5..1837665 100644 --- a/internal/server/templates.go +++ b/internal/server/templates.go @@ -81,9 +81,23 @@ func loadTemplates() (TemplateCollection, error) { } templates["index"] = index - glob := path.Join(templateDir, "blocks", "*.gotmpl") + glob := path.Join(templateDir, "*.gotmpl") templatePaths, err := fs.Glob(frontend.Files, glob) if err != nil { + return nil, errors.WithMessage(err, "could not glob main templates") + } + for _, fullname := range templatePaths { + tpl, err := loadTemplate(layoutFile, fullname) + if err != nil { + return nil, err + } + name, _ := strings.CutSuffix(path.Base(fullname), ".gotmpl") + templates[name] = tpl + } + + glob = path.Join(templateDir, "blocks", "*.gotmpl") + templatePaths, err = fs.Glob(frontend.Files, glob) + if err != nil { return nil, errors.WithMessage(err, "could not glob block templates") } for _, fullname := range templatePaths { |