Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add split function #3293

Merged
merged 1 commit into from Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/tmpl/tmpl.go
Expand Up @@ -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)
},
Expand Down
1 change: 1 addition & 0 deletions www/docs/customization/templates.md
Expand Up @@ -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) |
Expand Down