From c584eb1c4b3ad227c531555fc9545dc23f39993c Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 12 May 2024 13:51:33 -0400 Subject: [PATCH] docs(fix): update regenerated docs Signed-off-by: Dave Henderson --- docs/content/functions/coll.md | 20 +++++++-- docs/content/functions/data.md | 80 ++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/docs/content/functions/coll.md b/docs/content/functions/coll.md index 1f7bea070..6448ac9b2 100644 --- a/docs/content/functions/coll.md +++ b/docs/content/functions/coll.md @@ -629,7 +629,7 @@ map[foo:1 bar:5 baz:4] 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). @@ -649,7 +649,7 @@ map | coll.Pick keys... | name | description | |------|-------------| -| `keys...` | _(required)_ the keys to match | +| `keys...` | _(required)_ the keys (strings) to match | | `map` | _(required)_ the map to pick from | ### Examples @@ -659,12 +659,18 @@ $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} {{ coll.Pick "foo" "baz" $data }}' map[baz:3 foo:1] ``` +```console +$ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} +{{ $keys := coll.Slice "foo" "baz" }} +{{ coll.Pick $keys $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. +The keys can either be separate arguments, or a slice (since v4.0.0). This is the inverse of [`coll.Pick`](#coll-pick). @@ -684,7 +690,7 @@ map | coll.Omit keys... | name | description | |------|-------------| -| `keys...` | _(required)_ the keys to match | +| `keys...` | _(required)_ the keys (strings) to match | | `map` | _(required)_ the map to omit from | ### Examples @@ -694,3 +700,9 @@ $ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} {{ coll.Omit "foo" "baz" $data }}' map[bar:2] ``` +```console +$ gomplate -i '{{ $data := dict "foo" 1 "bar" 2 "baz" 3 }} +{{ $keys := coll.Slice "foo" "baz" }} +{{ coll.Omit $keys $data }}' +map[bar:2] +``` diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 9fd278f4f..1c3821572 100644 --- a/docs/content/functions/data.md +++ b/docs/content/functions/data.md @@ -536,6 +536,43 @@ Go COBOL ``` +## `data.CUE`_(unreleased)_ +**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ + +**Alias:** `cue` + +Converts a [CUE](https://cuelang.org/) document into an object. Any type +of CUE document is supported. This can be used to access properties of CUE +documents. + +Note that the `import` statement is not yet supported, and will result in +an error (except for importing builtin packages). + +### Usage + +``` +data.CUE input +``` +``` +input | data.CUE +``` + +### Arguments + +| name | description | +|------|-------------| +| `input` | _(required)_ the CUE document to parse | + +### Examples + +```console +$ gomplate -i '{{ $t := `data: { + hello: "world" + }` -}} + Hello {{ (cue $t).data.hello }}' +Hello world +``` + ## `data.ToJSON` **Alias:** `toJSON` @@ -726,3 +763,46 @@ first,second 1,2 3,4 ``` + +## `data.ToCUE`_(unreleased)_ +**Unreleased:** _This function is in development, and not yet available in released builds of gomplate._ + +**Alias:** `toCUE` + +Converts an object to a [CUE](https://cuelang.org/) document in canonical +format. The input object can be of any type. + +This is roughly equivalent to using the `cue export --out=cue ` +command to convert from other formats to CUE. + +### Usage + +``` +data.ToCUE input +``` +``` +input | data.ToCUE +``` + +### Arguments + +| name | description | +|------|-------------| +| `input` | _(required)_ the object to marshal as a CUE document | + +### Examples + +```console +$ gomplate -i '{{ `{"foo":"bar"}` | data.JSON | data.ToCUE }}' +{ + foo: "bar" +} +``` +```console +$ gomplate -i '{{ toCUE "hello world" }}' +"hello world" +``` +```console +$ gomplate -i '{{ coll.Slice 1 "two" true | data.ToCUE }}' +[1, "two", true] +```