From 006c0028106425abb3f718b2e86349dee5b7a2ea Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sun, 26 May 2024 21:43:49 +0200 Subject: Refactor how preprocess functions work a bit --- src/gmi/posts_preprocess_funcs.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/gmi/posts_preprocess_funcs.go (limited to 'src/gmi/posts_preprocess_funcs.go') diff --git a/src/gmi/posts_preprocess_funcs.go b/src/gmi/posts_preprocess_funcs.go new file mode 100644 index 0000000..f8fcda6 --- /dev/null +++ b/src/gmi/posts_preprocess_funcs.go @@ -0,0 +1,26 @@ +package gmi + +import ( + "fmt" + + "dev.mediocregopher.com/mediocre-blog.git/src/render" +) + +type postPreprocessFuncs struct { + urlBuilder render.URLBuilder +} + +func (f postPreprocessFuncs) Image(args ...string) (string, error) { + var ( + id = args[0] + descr = "Image" + ) + + if len(args) > 1 { + descr = args[1] + } + + return fmt.Sprintf( + "\n=> %s %s", f.urlBuilder.Asset(id), descr, + ), nil +} -- cgit v1.2.3