Home

blog @f4cd5442ea20b11b0e1f33e8a96c7abcc6f84e48 - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
blog / template.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
package blog

import (
	"fmt"
	"html/template"
	"io/fs"

	"github.com/bmatcuk/doublestar/v4"
)

func parseTemplates(fs fs.FS) (*template.Template, error) {
	matches, err := doublestar.Glob(fs, "**/*.html")
	if err != nil {
		return nil, fmt.Errorf("could not glob templates: %w", err)
	}
	tmpl, err := template.New("").ParseFiles(matches...)
	if err != nil {
		return nil, fmt.Errorf("could not parse templates: %w", err)
	}
	return tmpl, nil
}