summaryrefslogtreecommitdiff
path: root/docs-src
diff options
context:
space:
mode:
Diffstat (limited to 'docs-src')
-rw-r--r--docs-src/content/functions/coll.yml22
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: |