Skip to content

Commit

Permalink
docs(fix): update regenerated docs
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson committed May 12, 2024
1 parent 911e28c commit c584eb1
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 4 deletions.
20 changes: 16 additions & 4 deletions docs/content/functions/coll.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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
Expand All @@ -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).

Expand All @@ -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
Expand All @@ -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]
```
80 changes: 80 additions & 0 deletions docs/content/functions/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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 <file>`
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]
```

0 comments on commit c584eb1

Please sign in to comment.