Skip to content

Commit

Permalink
Document keyVals function
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring authored Sep 28, 2023
1 parent 4dba20d commit e77993b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions content/en/functions/keyvals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: keyVals
description: Returns a KeyVals struct.
categories: [functions]
menu:
docs:
parent: functions
keywords: []
namespace: collections
relatedFuncs: []
signature:
- collections.KeyVals KEY VALUES...
- keyVals KEY VALUES...

---

The primary application for this function is the definition of the `namedSlices` parameter in the options map passed to the `.Related` method on the `Page` object.

See [related content](/content-management/related).

```go-html-template
{{ $kv := keyVals "foo" "a" "b" "c" }}
```

The resulting data structure is:

```json
{
"Key": "foo",
"Values": [
"a",
"b",
"c"
]
}
```

To extract the key and values:

```go-html-template
{{ $kv.Key }} → foo
{{ $kv.Values }} → [a b c]
```

0 comments on commit e77993b

Please sign in to comment.