diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-10-10 22:21:59 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-10-10 23:09:04 -0400 |
| commit | 73fc71c4b09d77522ee90f2253fe04486e423a95 (patch) | |
| tree | a391c3a61c183d2f17b08b9e2ee9c898270e4eff /docs-src/content/functions/coll.yml | |
| parent | 64edc4ff89c5d6cc831842f4e612509e7db1d350 (diff) | |
New flatten/coll.Flatten function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs-src/content/functions/coll.yml')
| -rw-r--r-- | docs-src/content/functions/coll.yml | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs-src/content/functions/coll.yml b/docs-src/content/functions/coll.yml index 62d3cbcc..8a9917f1 100644 --- a/docs-src/content/functions/coll.yml +++ b/docs-src/content/functions/coll.yml @@ -200,6 +200,28 @@ funcs: - | $ gomplate -i '{{ slice 1 2 3 2 3 4 1 5 | uniq }}' [1 2 3 4 5] + - name: coll.Flatten + alias: flatten + description: | + Flatten a nested list. Defaults to completely flattening all nested lists, + but can be limited with `depth`. + + _Note that this function does not change the given list; it always produces a new one._ + pipeline: true + arguments: + - name: depth + required: false + description: maximum depth of nested lists to flatten. Omit or set to `-1` for infinite depth. + - name: list + required: true + description: the input list + examples: + - | + $ gomplate -i '{{ "[[1,2],[],[[3,4],[[[5],6],7]]]" | jsonArray | flatten }}' + [1 2 3 4 5 6 7] + - | + $ gomplate -i '{{ coll.Flatten 2 ("[[1,2],[],[[3,4],[[[5],6],7]]]" | jsonArray) }}' + [1 2 3 4 [[5] 6] 7] - name: coll.Reverse alias: reverse description: | |
