diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2024-05-26 21:43:49 +0200 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2024-05-26 21:43:49 +0200 |
commit | 006c0028106425abb3f718b2e86349dee5b7a2ea (patch) | |
tree | 47381f28793d97010fe60938eb7684a886dc885b /src/gmi/posts_preprocess_funcs.go | |
parent | 43d8951296ce2f232ca94f0577e2e726291bf783 (diff) |
Refactor how preprocess functions work a bit
Diffstat (limited to 'src/gmi/posts_preprocess_funcs.go')
-rw-r--r-- | src/gmi/posts_preprocess_funcs.go | 26 |
1 files changed, 26 insertions, 0 deletions
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 +} |