diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -55,6 +55,8 @@ Gomplate is an alternative that will let you process templates which also includ - [Example](#example) - [`split`](#split) - [Example](#example) + - [`splitN`](#splitn) + - [Example](#example) - [`title`](#title) - [Example](#example) - [`toLower`](#tolower) @@ -361,20 +363,26 @@ Creates a slice by splitting a string on a given delimiter. Equivalent to ##### Example -_`input.tmpl`:_ -``` -{{range split "Bart,Lisa,Maggie"}} -Hello, {{.}} -{{- end}} -``` - ```console -$ gomplate < input.tmpl +$ gomplate -i '{{range split "Bart,Lisa,Maggie" ","}}Hello, {{.}}{{end}}' Hello, Bart Hello, Lisa Hello, Maggie ``` +#### `splitN` + +Creates a slice by splitting a string on a given delimiter. The count determines +the number of substrings to return. Equivalent to [strings.SplitN](https://golang.org/pkg/strings#SplitN) + +##### Example + +```console +$ gomplate -i '{{ range splitN "foo:bar:baz" ":" 2 }}{{.}}{{end}}' +foo +bar:baz +``` + #### `title` Convert to title-case. Equivalent to [strings.Title](https://golang.org/pkg/strings/#Title) |
