hugo/content/en/functions/dict.md
Bjørn Erik Pedersen b9bd35d72e Squashed 'docs/' content from commit fdea5430f
git-subtree-dir: docs
git-subtree-split: fdea5430f89dfd849d39212abdf5ace0a4763e5a
2019-10-21 10:22:28 +02:00

1.9 KiB

title description godocref workson date publishdate lastmod categories menu keywords signature workson hugoversion relatedfuncs deprecated aliases
dict Creates a dictionary from a list of key and value pairs.
2017-02-01 2017-02-01 2017-02-26
functions
docs
parent
functions
dictionary
dict KEY VALUE [KEY VALUE]...
false

dict is especially useful for passing more than one value to a partial template.

Example: Using dict to pass multiple values to a partial

The partial below creates a SVG and expects fill, height and width from the caller:

Partial definition

{{< code file="layouts/partials/svgs/external-links.svg" download="external-links.svg" >}} {{< /code >}}

Partial call

The fill, height and width values can be stored in one object with dict and passed to the partial:

{{< code file="layouts/_default/list.html" >}} {{ partial "svgs/external-links.svg" (dict "fill" "#01589B" "width" 10 "height" 20 ) }} {{< /code >}}