Skip to content

Commit

Permalink
feat: add split tmpl function (#3293)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Aug 7, 2022
1 parent d630605 commit 42eaf08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/tmpl/tmpl.go
Expand Up @@ -176,6 +176,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)
},
Expand Down
1 change: 1 addition & 0 deletions www/docs/customization/templates.md
Expand Up @@ -96,6 +96,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) |
Expand Down

0 comments on commit 42eaf08

Please sign in to comment.