From ab982b5b04776715d5ad2095ca4bba0b67d2e986 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 12 May 2024 12:37:46 -0400 Subject: feat: coll.Pick now supports slice of strings as input (#2069) Signed-off-by: Dave Henderson --- docs-src/content/functions/coll.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'docs-src') 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] -- cgit v1.2.3