summaryrefslogtreecommitdiff
path: root/templates.go
diff options
context:
space:
mode:
Diffstat (limited to 'templates.go')
-rw-r--r--templates.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/templates.go b/templates.go
index ddce7ea..e31f06f 100644
--- a/templates.go
+++ b/templates.go
@@ -8,3 +8,21 @@ import (
//go:embed templates/*.gmi
var geminiTemplateFS embed.FS
var geminiTemplate = template.Must(template.ParseFS(geminiTemplateFS, "templates/*.gmi"))
+
+func addTemplates(base *template.Template, additions *template.Template) (*template.Template, error) {
+ base, err := base.Clone()
+ if err != nil {
+ return nil, err
+ }
+ if additions == nil {
+ return base, nil
+ }
+
+ for _, addition := range additions.Templates() {
+ if _, err := base.AddParseTree(addition.Name(), addition.Tree); err != nil {
+ return nil, err
+ }
+ }
+
+ return base, nil
+}