diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2024-05-12 12:37:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-12 16:37:46 +0000 |
| commit | ab982b5b04776715d5ad2095ca4bba0b67d2e986 (patch) | |
| tree | 25fe677bdf2b9ccd169745914f56de3e99aaed2c /docs-src | |
| parent | 916ebe6ea6d0319a37f0c4b62fd5e4a189f3dc50 (diff) | |
feat: coll.Pick now supports slice of strings as input (#2069)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs-src')
| -rw-r--r-- | docs-src/content/functions/coll.yml | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/docs-src/content/functions/coll.yml b/docs-src/content/functions/coll.yml index 4302239a..06027130 100644 --- a/docs-src/content/functions/coll.yml +++ b/docs-src/content/functions/coll.yml @@ -410,7 +410,7 @@ funcs: description: | Given a map, returns a new map with any entries that have the given keys. - All keys are converted to strings. + The keys can either be separate arguments, or a slice (since v4.0.0). This is the inverse of [`coll.Omit`](#coll-omit). @@ -419,7 +419,7 @@ funcs: arguments: - name: keys... required: true - description: the keys to match + description: the keys (strings) to match - name: map required: true description: the map to pick from @@ -428,12 +428,17 @@ funcs: $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} {{ coll.Pick "foo" "baz" $data }}' map[baz:3 foo:1] + - | + $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} + {{ $keys := coll.Slice "foo" "baz" }} + {{ coll.Pick $keys $data }}' + map[baz:3 foo:1] - name: coll.Omit released: v3.7.0 description: | Given a map, returns a new map without any entries that have the given keys. - All keys are converted to strings. + The keys can either be separate arguments, or a slice (since v4.0.0). This is the inverse of [`coll.Pick`](#coll-pick). @@ -442,7 +447,7 @@ funcs: arguments: - name: keys... required: true - description: the keys to match + description: the keys (strings) to match - name: map required: true description: the map to omit from @@ -451,3 +456,8 @@ funcs: $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} {{ coll.Omit "foo" "baz" $data }}' map[bar:2] + - | + $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} + {{ $keys := coll.Slice "foo" "baz" }} + {{ coll.Omit $keys $data }}' + map[bar:2] |
