mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
2c0d1ccdcd
73f355ce Update theme 83ff50c2 Use example.com in examples 71292134 Add alias news > release-notes 2e15f642 Update theme 8eef09d2 Add Pygments configuration 572b9e75 Clean up the code shortcode use a1b2fd3b Remove the code fence language codes 1473b1d9 Remove redundant text b92c2042 Update theme 8f439c28 Edit contributing section in README 8bcf8a19 Add contributing section to README 4c44ee1c Fix broken content file 2bdc7710 Clarify .Data.Pages sorting in lists.md 092271c2 Use infinitive mood for main titles b9b8abef Update theme to reflect change to home page content b897b71b Change copy to use sentence case fd675ee5 Enable RSS feed for sections 060a5e27 Correct movie title in taxonomies.md 6a5ca96a Update displayed site name for Hub 22f4b7a4 Add example of starting up the local server d9612cb3 Update theme a8c3988a Update theme 4198189d Update theme 12d6b016 Update theme 2b1c4197 Update theme b6d90a1e Fix News release titles cfe751db Add some build info to README git-subtree-dir: docs git-subtree-split: 73f355ce0dd88d032062ea70067431ab980cdd8d
43 lines
1.8 KiB
Markdown
43 lines
1.8 KiB
Markdown
---
|
|
title: dict
|
|
description: Creates a dictionary from a list of key and value pairs.
|
|
godocref:
|
|
workson: []
|
|
date: 2017-02-01
|
|
publishdate: 2017-02-01
|
|
lastmod: 2017-02-26
|
|
categories: [functions]
|
|
menu:
|
|
docs:
|
|
parent: "functions"
|
|
#tags: [dictionary]
|
|
signature: ["dict KEY VALUE [KEY VALUE]..."]
|
|
workson: []
|
|
hugoversion:
|
|
relatedfuncs: []
|
|
deprecated: false
|
|
aliases: []
|
|
---
|
|
|
|
`dict` is especially useful for passing more than one value to a partial template.
|
|
|
|
|
|
## Example: `dict` with Embedded SVGs
|
|
|
|
The partial below creates a SVG and expects `fill` `height` and `width` from the caller:
|
|
|
|
{{< code file="layouts/partials/svgs/external-links.svg" download="external-links.svg" >}}
|
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="{{ .fill }}" width="{{ .size }}" height="{{ .size }}" viewBox="0 0 32 32" aria-label="External Link">
|
|
<path d="M25.152 16.576v5.696q0 2.144-1.504 3.648t-3.648 1.504h-14.848q-2.144 0-3.648-1.504t-1.504-3.648v-14.848q0-2.112 1.504-3.616t3.648-1.536h12.576q0.224 0 0.384 0.16t0.16 0.416v1.152q0 0.256-0.16 0.416t-0.384 0.16h-12.576q-1.184 0-2.016 0.832t-0.864 2.016v14.848q0 1.184 0.864 2.016t2.016 0.864h14.848q1.184 0 2.016-0.864t0.832-2.016v-5.696q0-0.256 0.16-0.416t0.416-0.16h1.152q0.256 0 0.416 0.16t0.16 0.416zM32 1.152v9.12q0 0.48-0.352 0.8t-0.8 0.352-0.8-0.352l-3.136-3.136-11.648 11.648q-0.16 0.192-0.416 0.192t-0.384-0.192l-2.048-2.048q-0.192-0.16-0.192-0.384t0.192-0.416l11.648-11.648-3.136-3.136q-0.352-0.352-0.352-0.8t0.352-0.8 0.8-0.352h9.12q0.48 0 0.8 0.352t0.352 0.8z"></path>
|
|
</svg>
|
|
{{< /code >}}
|
|
|
|
These values can be stored in one object with `dict` and passed to the partial:
|
|
|
|
{{< code file="layouts/_default/list.html" >}}
|
|
{{ partial "svg/link-ext.svg" (dict "fill" "#01589B" "size" 10 "width" 20 ) }}
|
|
{{< /code >}}
|
|
|
|
|
|
|
|
[partials]: /templates/partials/
|