Skip to content

Commit

Permalink
Documenting join, and adding an integration test for it
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
  • Loading branch information
hairyhenderson committed May 19, 2017
1 parent 06abd44 commit 8a45646
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Gomplate is an alternative that will let you process templates which also includ
- [`trim`](#trim)
- [`urlParse`](#urlparse)
- [`has`](#has)
- [`join`](#join)
- [`indent`](#indent)
- [`json`](#json)
- [`jsonArray`](#jsonarray)
Expand Down Expand Up @@ -489,6 +490,23 @@ $ gomplate -d vault:///secret/foo < input.tmpl
The secret is 'foo: bar'
```

#### `join`

Concatenates the elements of an array to create a string. The separator string sep is placed between elements in the resulting string.

##### Example

_`input.tmpl`_
```
{{ $a := `[1, 2, 3]` | jsonArray }}
{{ join $a "-" }}
```

```console
$ gomplate -f input.tmpl
1-2-3
```

#### `indent`

Indents a given string with the given indentation pattern. If the input string has multiple lines, each line will be indented.
Expand Down
6 changes: 6 additions & 0 deletions test/integration/typeconv_funcs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ function teardown () {
multiline
world" ]]
}

@test "join" {
gomplate -i '{{ $a := `[1, 2, 3]` | jsonArray }}{{ join $a "-" }}'
[ "$status" -eq 0 ]
[[ "${output}" == "1-2-3" ]]
}

0 comments on commit 8a45646

Please sign in to comment.