From 2ce5be68acd3c66d4d135d7eb68b9ecd1563aa1d Mon Sep 17 00:00:00 2001 From: tjpcc Date: Fri, 1 Sep 2023 12:36:46 -0600 Subject: simplify internal gemini template-handling functions --- gemini/gemtext/internal/templates.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'gemini') diff --git a/gemini/gemtext/internal/templates.go b/gemini/gemtext/internal/templates.go index 3ca7224..4ae9f3f 100644 --- a/gemini/gemtext/internal/templates.go +++ b/gemini/gemtext/internal/templates.go @@ -22,16 +22,13 @@ func AddAllTemplates(base *template.Template, additions *template.Template) (*te return base, nil } - tmpl := base - var err error for _, addition := range additions.Templates() { - tmpl, err = tmpl.AddParseTree(addition.Name(), addition.Tree) - if err != nil { + if _, err := base.AddParseTree(addition.Name(), addition.Tree); err != nil { return nil, err } } - return tmpl, nil + return base, nil } func AddHTMLTemplates(base *htemplate.Template, additions *htemplate.Template) (*htemplate.Template, error) { @@ -39,16 +36,13 @@ func AddHTMLTemplates(base *htemplate.Template, additions *htemplate.Template) ( return base, nil } - tmpl := base - var err error for _, addition := range additions.Templates() { - tmpl, err = tmpl.AddParseTree(addition.Name(), addition.Tree) - if err != nil { + if _, err := base.AddParseTree(addition.Name(), addition.Tree); err != nil { return nil, err } } - return tmpl, nil + return base, nil } func ValidateLinks(doc gemtext.Document) error { -- cgit v1.2.3