github.com/shohhei1126/hugo@v0.42.2-0.20180623210752-3d5928889ad7/docs/content/en/functions/cond.md (about)

     1  ---
     2  title: "cond"
     3  date: 2017-09-08
     4  description: "Return one of two arguments, depending on the value of a third argument."
     5  categories: [functions]
     6  menu:
     7    docs:
     8      parent: "functions"
     9  signature: ["cond CONTROL VAR1 VAR2"]
    10  aliases: [/functions/cond/]
    11  hugoversion: 0.27
    12  relatedfuncs: [default]
    13  toc: false
    14  draft: false
    15  needsexamples: false
    16  ---
    17  
    18  `cond` returns *VAR1* if *CONTROL* is true, or *VAR2* if it is not.
    19  
    20  Example:
    21  
    22  ```
    23  {{ cond (eq (len $geese) 1) "goose" "geese" }}
    24  ```
    25  
    26  Would emit "goose" if the `$geese` array has exactly 1 item, or "geese" otherwise.
    27  
    28  {{% warning %}}
    29  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*.
    30  
    31  In other words, the `cond` function does *not* provide [short-circuit evaluation](https://en.wikipedia.org/wiki/Short-circuit_evaluation) and does *not* work like a normal [ternary operator](https://en.wikipedia.org/wiki/%3F:) that will pass over the first expression if the condition returns `false`.
    32  {{% /warning %}}