mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,12 +3,11 @@ title: compare.Conditional
|
||||
description: Returns one of two arguments depending on the value of the control argument.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [cond]
|
||||
related:
|
||||
- functions/compare/Default
|
||||
returnType: any
|
||||
signatures: [compare.Conditional CONTROL ARG1 ARG2]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [cond]
|
||||
returnType: any
|
||||
signatures: [compare.Conditional CONTROL ARG1 ARG2]
|
||||
aliases: [/functions/cond]
|
||||
---
|
||||
|
||||
|
@@ -2,27 +2,24 @@
|
||||
title: compare.Default
|
||||
description: Returns the second argument if set, else the first argument.
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [default]
|
||||
related:
|
||||
- functions/compare/Conditional
|
||||
- functions/go-template/Or
|
||||
returnType: any
|
||||
signatures: [compare.Default DEFAULT INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [default]
|
||||
returnType: any
|
||||
signatures: [compare.Default DEFAULT INPUT]
|
||||
aliases: [/functions/default]
|
||||
---
|
||||
|
||||
The `default` function returns the second argument if set, else the first argument.
|
||||
|
||||
{{% note %}}
|
||||
When the second argument is the boolean `false` value, the `default` function returns `false`. All _other_ falsy values are considered unset.
|
||||
|
||||
{{% include "functions/go-template/_common/truthy-falsy.md" %}}
|
||||
|
||||
To set a default value based on truthiness, use the [`or`] operator instead.
|
||||
|
||||
[`or`]: /functions/go-template/or/
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> When the second argument is the boolean `false` value, the `default` function returns `false`. All _other_ falsy values are considered unset.
|
||||
>
|
||||
> The falsy values are `false`, `0`, any `nil` pointer or interface value, any array, slice, map, or string of length zero, and zero `time.Time` values.
|
||||
>
|
||||
> Everything else is truthy.
|
||||
>
|
||||
> To set a default value based on truthiness, use the [`or`] operator instead.
|
||||
|
||||
The `default` function returns the second argument if set:
|
||||
|
||||
@@ -46,3 +43,5 @@ The `default` function returns the first argument if the second argument is not
|
||||
{{ default 42 slice }} → 42
|
||||
{{ default 42 <nil> }} → 42
|
||||
```
|
||||
|
||||
[`or`]: /functions/go-template/or/
|
||||
|
@@ -3,16 +3,11 @@ title: compare.Eq
|
||||
description: Returns the boolean truth of arg1 == arg2 || arg1 == arg3.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [eq]
|
||||
related:
|
||||
- functions/compare/Ge
|
||||
- functions/compare/Gt
|
||||
- functions/compare/Le
|
||||
- functions/compare/Lt
|
||||
- functions/compare/Ne
|
||||
returnType: bool
|
||||
signatures: ['compare.Eq ARG1 ARG2 [ARG...]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [eq]
|
||||
returnType: bool
|
||||
signatures: ['compare.Eq ARG1 ARG2 [ARG...]']
|
||||
aliases: [/functions/eq]
|
||||
---
|
||||
|
||||
|
@@ -3,16 +3,11 @@ title: compare.Ge
|
||||
description: Returns the boolean truth of arg1 >= arg2 && arg1 >= arg3.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [ge]
|
||||
related:
|
||||
- functions/compare/Eq
|
||||
- functions/compare/Gt
|
||||
- functions/compare/Le
|
||||
- functions/compare/Lt
|
||||
- functions/compare/Ne
|
||||
returnType: bool
|
||||
signatures: ['compare.Ge ARG1 ARG2 [ARG...]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [ge]
|
||||
returnType: bool
|
||||
signatures: ['compare.Ge ARG1 ARG2 [ARG...]']
|
||||
aliases: [/functions/ge]
|
||||
---
|
||||
|
||||
|
@@ -3,16 +3,11 @@ title: compare.Gt
|
||||
description: Returns the boolean truth of arg1 > arg2 && arg1 > arg3.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [gt]
|
||||
related:
|
||||
- functions/compare/Eq
|
||||
- functions/compare/Ge
|
||||
- functions/compare/Le
|
||||
- functions/compare/Lt
|
||||
- functions/compare/Ne
|
||||
returnType: bool
|
||||
signatures: ['compare.Gt ARG1 ARG2 [ARG...]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [gt]
|
||||
returnType: bool
|
||||
signatures: ['compare.Gt ARG1 ARG2 [ARG...]']
|
||||
aliases: [/functions/gt]
|
||||
---
|
||||
|
||||
|
@@ -3,16 +3,11 @@ title: compare.Le
|
||||
description: Returns the boolean truth of arg1 <= arg2 && arg1 <= arg3.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [le]
|
||||
related:
|
||||
- functions/compare/Eq
|
||||
- functions/compare/Ge
|
||||
- functions/compare/Gt
|
||||
- functions/compare/Lt
|
||||
- functions/compare/Ne
|
||||
returnType: bool
|
||||
signatures: ['compare.Le ARG1 ARG2 [ARG...]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [le]
|
||||
returnType: bool
|
||||
signatures: ['compare.Le ARG1 ARG2 [ARG...]']
|
||||
aliases: [/functions/le]
|
||||
---
|
||||
|
||||
|
@@ -3,16 +3,11 @@ title: compare.Lt
|
||||
description: Returns the boolean truth of arg1 < arg2 && arg1 < arg3.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [lt]
|
||||
related:
|
||||
- functions/compare/Eq
|
||||
- functions/compare/Ge
|
||||
- functions/compare/Gt
|
||||
- functions/compare/Le
|
||||
- functions/compare/Ne
|
||||
returnType: bool
|
||||
signatures: ['compare.Lt ARG1 ARG2 [ARG...]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [lt]
|
||||
returnType: bool
|
||||
signatures: ['compare.Lt ARG1 ARG2 [ARG...]']
|
||||
aliases: [/functions/lt]
|
||||
---
|
||||
|
||||
|
@@ -3,16 +3,11 @@ title: compare.Ne
|
||||
description: Returns the boolean truth of arg1 != arg2 && arg1 != arg3.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [ne]
|
||||
related:
|
||||
- functions/compare/Eq
|
||||
- functions/compare/Ge
|
||||
- functions/compare/Gt
|
||||
- functions/compare/Le
|
||||
- functions/compare/Lt
|
||||
returnType: bool
|
||||
signatures: ['compare.Ne ARG1 ARG2 [ARG...]']
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [ne]
|
||||
returnType: bool
|
||||
signatures: ['compare.Ne ARG1 ARG2 [ARG...]']
|
||||
aliases: [/functions/ne]
|
||||
---
|
||||
|
||||
|
@@ -1,12 +1,7 @@
|
||||
---
|
||||
title: Compare functions
|
||||
linkTitle: compare
|
||||
description: Template functions to compare two or more values.
|
||||
description: Use these functions to compare two or more values.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these functions to compare two or more values.
|
||||
|
Reference in New Issue
Block a user