mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-14 20:37:55 -05:00
ec920363cd
4c5edacfe cSpell config update (#1700) 9df788b25 Fix broken link (hugo modules) (#1710) 9928a70d6 Fix workspace formatting (#1707) 55467e7c8 Update partials.md 9f4bd0023 Update formats.md 9b3913c86 Remove footnoteAnchorPrefix and footnoteReturnLinkContents (#1704) 94502a09b Code block render hooks are introduced in v0.93.0 (#1701) c447270ef Update sitemap-template.md 78665c1e0 Update sitemap-template.md 60653c17d Update the caddy error docs link (#1696) 9a3675aad Update sitemap templates (#1699) e0d08cdbb Add wpxr-to-static to list of migration tools (#1512) b53eb5a08 Add page for deploying with rclone (#1511) 4207c57ff netlify: Hugo 0.96.0 a18d646ea docs: Regen docshelper e3e0981ed docs: Regen CLI docs fda988d01 Merge commit 'd276e901b36d2576ef8350ed96b17f66254eac1b' e4a26dbca tpl/crypto: Add optional encoding arg to hmac function git-subtree-dir: docs git-subtree-split: 4c5edacfeebd13eb7f876723c065466cd50e0cae
1.1 KiB
1.1 KiB
title | date | description | categories | menu | signature | hugoversion | relatedfuncs | toc | draft | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cond | 2017-09-08 | Return one of two arguments, depending on the value of a third argument. |
|
|
|
0.27 |
|
false | false |
cond
returns VAR1 if CONTROL is true, or VAR2 if it is not.
Example:
{{ cond (eq (len $geese) 1) "goose" "geese" }}
Would emit "goose" if the $geese
array has exactly 1 item, or "geese" otherwise.
{{% warning %}}
Whenever you use a cond
function, both variable expressions are always evaluated. This means that a usage like cond false (div 1 0) 27
will throw an error because div 1 0
will be evaluated even though the condition is false.
In other words, the cond
function does not provide short-circuit evaluation and does not work like a normal ternary operator that will pass over the first expression if the condition returns false
.
{{% /warning %}}