hugo/content/en/functions/collections/KeyVals.md
Bjørn Erik Pedersen 9b0050e9aa Squashed 'docs/' content from commit 5c085a37b
git-subtree-dir: docs
git-subtree-split: 5c085a37b297bf12f59efeaae591418ec025c10d
2024-01-27 10:48:33 +01:00

820 B

title description categories keywords action aliases
collections.KeyVals Returns a KeyVals struct.
aliases related returnType signatures
keyVals
methods/pages/Related
types.KeyValues
collections.KeyVals KEY VALUES...
/functions/keyvals

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

See related content.

{{ $kv := keyVals "foo" "a" "b" "c" }}

The resulting data structure is:

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

To extract the key and values:

{{ $kv.Key }} → foo
{{ $kv.Values }} → [a b c]