summaryrefslogtreecommitdiff
path: root/src/post
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2023-01-22 12:45:03 +0100
committerBrian Picciano <mediocregopher@gmail.com>2023-01-22 12:45:03 +0100
commit5b5a0438682ecb69bbc8d7cb9904ad4b049033a3 (patch)
treebf5a689a3df4cbf9bd6188928d79d67517be63b3 /src/post
parent1cfdac5e8c2ac802275cb29ae9149c55547f38fb (diff)
Implement gemini atom feed
Diffstat (limited to 'src/post')
-rw-r--r--src/post/preprocess.go18
1 files changed, 11 insertions, 7 deletions
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)