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
}
|