From 3ca4f8944e4f4ea43c53f1fed074e4199f04074d Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Mon, 4 May 2020 22:11:23 -0400 Subject: New functions coll.Pick and coll.Omit Signed-off-by: Dave Henderson --- docs-src/content/functions/coll.yml | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'docs-src/content') diff --git a/docs-src/content/functions/coll.yml b/docs-src/content/functions/coll.yml index 8a9917f1..cf267fe1 100644 --- a/docs-src/content/functions/coll.yml +++ b/docs-src/content/functions/coll.yml @@ -301,3 +301,47 @@ funcs: {{ $src2 := dict "foo" 3 "bar" 5 }} {{ coll.Merge $dst $src1 $src2 }}' map[foo:1 bar:5 baz:4] + - name: coll.Pick + description: | + Given a map, returns a new map with any entries that have the given keys. + + All keys are converted to strings. + + This is the inverse of [`coll.Omit`](#coll-omit). + + _Note that this function does not modify the input._ + pipeline: true + arguments: + - name: keys... + required: true + description: the keys to match + - name: map + required: true + description: the map to pick from + examples: + - | + $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} + {{ coll.Pick "foo" "baz" $data }}' + map[baz:3 foo:1] + - name: coll.Omit + description: | + Given a map, returns a new map without any entries that have the given keys. + + All keys are converted to strings. + + This is the inverse of [`coll.Pic`](#coll-pick). + + _Note that this function does not modify the input._ + pipeline: true + arguments: + - name: keys... + required: true + description: the keys to match + - name: map + required: true + description: the map to omit from + examples: + - | + $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} + {{ coll.Omit "foo" "baz" $data }}' + map[bar:2] -- cgit v1.2.3