diff options
author | Alan Pearce | 2024-06-21 13:02:08 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-21 15:33:38 +0200 |
commit | fc5fd2edd9b8282497e33a18300eab694d8a89c6 (patch) | |
tree | 18af097c037ef781cc8f6148d7c1ba37e10877c1 /internal/server/templates.go | |
parent | cac323d9ae70f55a43fd99b73e60cf614be11797 (diff) | |
download | searchix-fc5fd2edd9b8282497e33a18300eab694d8a89c6.tar.lz searchix-fc5fd2edd9b8282497e33a18300eab694d8a89c6.tar.zst searchix-fc5fd2edd9b8282497e33a18300eab694d8a89c6.zip |
refactor: switch to templ for HTML templates
Diffstat (limited to 'internal/server/templates.go')
-rw-r--r-- | internal/server/templates.go | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/internal/server/templates.go b/internal/server/templates.go index 38ff5d4..fa95425 100644 --- a/internal/server/templates.go +++ b/internal/server/templates.go @@ -95,21 +95,13 @@ func loadTemplates() (TemplateCollection, error) { templateDir := "templates" templates := make(TemplateCollection, 0) - layoutFile := path.Join(templateDir, "index.gotmpl") - - index, err := loadTemplate(layoutFile) - if err != nil { - return nil, err - } - templates["index"] = index - 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) + tpl, err := loadTemplate(fullname) if err != nil { return nil, err } @@ -117,20 +109,5 @@ func loadTemplates() (TemplateCollection, error) { 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 { - tpl, err := loadTemplate(layoutFile, glob, fullname) - if err != nil { - return nil, err - } - - name, _ := strings.CutSuffix(path.Base(fullname), ".gotmpl") - templates[name] = tpl - } - return templates, nil } |