1
0
Fork 0
hugo/docs/content/en/functions/collections/KeyVals.md

816 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 VALUE...
/functions/keyvals

The primary application for this function is the definition of the namedSlices value 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]