diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-09-16 21:04:50 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-09-16 21:04:50 -0600 |
commit | f2b044364129ee9e4f66348e747bd53b4d7e55ac (patch) | |
tree | 30dd86661efa3ed179d99b95c2ba663dbe367cc2 /templates.go | |
parent | a38d04936cd859711dfb0938d5cb998ffc9ce247 (diff) |
support template overrides
Diffstat (limited to 'templates.go')
-rw-r--r-- | templates.go | 18 |
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 +} |