summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2020-05-04 22:11:23 -0400
committerDave Henderson <dhenderson@gmail.com>2020-05-04 22:20:58 -0400
commit3ca4f8944e4f4ea43c53f1fed074e4199f04074d (patch)
tree5b091e0579a7fc3773d39d065c53dd3e16822610 /docs
parent8f6ec3d319569029b7f81d4c1eca4c359328d177 (diff)
New functions coll.Pick and coll.Omit
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/content/functions/coll.md68
1 files changed, 68 insertions, 0 deletions
diff --git a/docs/content/functions/coll.md b/docs/content/functions/coll.md
index 6ce9645b..31878333 100644
--- a/docs/content/functions/coll.md
+++ b/docs/content/functions/coll.md
@@ -484,3 +484,71 @@ $ gomplate -i '{{ $dst := dict "foo" 1 "bar" 2 }}
{{ coll.Merge $dst $src1 $src2 }}'
map[foo:1 bar:5 baz:4]
```
+
+## `coll.Pick`
+
+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._
+
+### Usage
+
+```go
+coll.Pick keys... map
+```
+```go
+map | coll.Pick keys...
+```
+
+### Arguments
+
+| name | description |
+|------|-------------|
+| `keys...` | _(required)_ the keys to match |
+| `map` | _(required)_ the map to pick from |
+
+### Examples
+
+```console
+$ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}
+{{ coll.Pick "foo" "baz" $data }}'
+map[baz:3 foo:1]
+```
+
+## `coll.Omit`
+
+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._
+
+### Usage
+
+```go
+coll.Omit keys... map
+```
+```go
+map | coll.Omit keys...
+```
+
+### Arguments
+
+| name | description |
+|------|-------------|
+| `keys...` | _(required)_ the keys to match |
+| `map` | _(required)_ the map to omit from |
+
+### Examples
+
+```console
+$ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }}
+{{ coll.Omit "foo" "baz" $data }}'
+map[bar:2]
+```