From 5b5a0438682ecb69bbc8d7cb9904ad4b049033a3 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 22 Jan 2023 12:45:03 +0100 Subject: Implement gemini atom feed --- src/post/preprocess.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/post/preprocess.go') diff --git a/src/post/preprocess.go b/src/post/preprocess.go index 4d4be9d..424c7b8 100644 --- a/src/post/preprocess.go +++ b/src/post/preprocess.go @@ -37,6 +37,16 @@ type PreprocessFunctions struct { Image func(args ...string) (string, error) } +func (funcs PreprocessFunctions) ToFuncsMap() template.FuncMap { + return template.FuncMap{ + "BlogURL": funcs.BlogURL, + "AssetURL": funcs.AssetURL, + "PostURL": funcs.PostURL, + "StaticURL": funcs.StaticURL, + "Image": funcs.Image, + } +} + // PreprocessBody interprets the Post's Body as a text template which may use // any of the functions found in PreprocessFunctions (all must be set). It // executes the template and writes the result to the given writer. @@ -44,13 +54,7 @@ func (p Post) PreprocessBody(into io.Writer, funcs PreprocessFunctions) error { tpl := template.New("") - tpl.Funcs(template.FuncMap{ - "BlogURL": funcs.BlogURL, - "AssetURL": funcs.AssetURL, - "PostURL": funcs.PostURL, - "StaticURL": funcs.StaticURL, - "Image": funcs.Image, - }) + tpl.Funcs(funcs.ToFuncsMap()) tpl, err := tpl.Parse(p.Body) -- cgit v1.2.3