diff options
author | Alan Pearce | 2024-06-21 13:02:08 +0200 |
---|---|---|
committer | Alan Pearce | 2024-06-21 15:44:12 +0200 |
commit | a1dfc548198a1326e71f1dd70303a5d3441f7a39 (patch) | |
tree | 03e7d60dc389678ee7cadaac4d5e64596dffde91 /internal/server/templates.go | |
parent | cac323d9ae70f55a43fd99b73e60cf614be11797 (diff) | |
download | searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.lz searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.tar.zst searchix-a1dfc548198a1326e71f1dd70303a5d3441f7a39.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 } |