-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplates.go
More file actions
44 lines (33 loc) · 1.04 KB
/
Copy pathtemplates.go
File metadata and controls
44 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
_ "embed"
"fmt"
"html/template"
"os"
)
//go:embed template.html
var TEMPLATE string
// var templates map[string]*template.Template
var templates *template.Template
func parseTemplates(inputFiles []string) error {
// templates = make(map[string]*template.Template)
templates = template.New("maretosi")
for _, templateFile := range inputFiles {
// name := extractSubpath(templateFile, templDir)
// t := template.New(name)
file, err := os.ReadFile(templateFile)
if err != nil {
return fmt.Errorf("failed to read template file %q: %w", templateFile, err)
}
if _, err := templates.Parse(string(file)); err != nil {
return fmt.Errorf("failed to parse template file %q: %w", templateFile, err)
}
// templates[name] = t
}
// t := template.New("__built_in")
if _, err := templates.Parse(TEMPLATE); err != nil {
return fmt.Errorf("failed to parse built-in template. This is a bug. Please consider reporting it at https://github.com/dogue/maretosi/issues")
}
// templates["__built_in"] = t
return nil
}