From b462a14f95d430186c4fc2c8f033f0e3023336e7 Mon Sep 17 00:00:00 2001 From: andig Date: Sun, 7 Aug 2022 12:52:44 +0200 Subject: [PATCH] Add split function --- internal/tmpl/tmpl.go | 1 + www/docs/customization/templates.md | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/tmpl/tmpl.go b/internal/tmpl/tmpl.go index 6000db4912c..e517b2039f7 100644 --- a/internal/tmpl/tmpl.go +++ b/internal/tmpl/tmpl.go @@ -174,6 +174,7 @@ func (t *Template) Apply(s string) (string, error) { Option("missingkey=error"). Funcs(template.FuncMap{ "replace": strings.ReplaceAll, + "split": strings.Split, "time": func(s string) string { return time.Now().UTC().Format(s) }, diff --git a/www/docs/customization/templates.md b/www/docs/customization/templates.md index cc775457352..3302fbb3305 100644 --- a/www/docs/customization/templates.md +++ b/www/docs/customization/templates.md @@ -95,6 +95,7 @@ On all fields, you have these available functions: | Usage | Description | |--------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | `replace "v1.2" "v" ""` | replaces all matches. See [ReplaceAll](https://golang.org/pkg/strings/#ReplaceAll) | +| `split "1.2" "."` | split string at separator. See [Split](https://golang.org/pkg/strings/#Split) | | `time "01/02/2006"` | current UTC time in the specified format (this is not deterministic, a new time for every call) | | `tolower "V1.2"` | makes input string lowercase. See [ToLower](https://golang.org/pkg/strings/#ToLower) | | `toupper "v1.2"` | makes input string uppercase. See [ToUpper](https://golang.org/pkg/strings/#ToUpper) |