docs: Prepare for new sub tree

See #11925
This commit is contained in:
Bjørn Erik Pedersen
2024-01-27 10:47:28 +01:00
parent 1083bf7c08
commit fc7de7136a
1157 changed files with 0 additions and 64232 deletions

View File

@@ -1,41 +0,0 @@
---
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]
aliases: [/functions/cond]
---
The CONTROL argument is a boolean value that indicates whether the function should return ARG1 or ARG2. If CONTROL is `true`, the function returns ARG1. Otherwise, the function returns ARG2.
```go-html-template
{{ $qty := 42 }}
{{ cond (le $qty 3) "few" "many" }} → many
```
The CONTROL argument must be either `true` or `false`. To cast a non-boolean value to boolean, pass it through the `not` operator twice.
```go-html-template
{{ cond (42 | not | not) "truthy" "falsy" }} → truthy
{{ cond ("" | not | not) "truthy" "falsy" }} → falsy
```
{{% note %}}
Unlike [ternary operators] in other languages, the `cond` function does not perform [short-circuit evaluation]. The function evaluates both ARG1 and ARG2, regardless of the CONTROL value.
[short-circuit evaluation]: https://en.wikipedia.org/wiki/Short-circuit_evaluation
[ternary operators]: https://en.wikipedia.org/wiki/Ternary_conditional_operator
{{% /note %}}
Due to the absence of short-circuit evaluation, these examples throw an error:
```go-html-template
{{ cond true "true" (div 1 0) }}
{{ cond false (div 1 0) "false" }}
```

View File

@@ -1,48 +0,0 @@
---
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]
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 %}}
The `default` function returns the second argument if set:
```go-html-template
{{ default 42 1 }} → 1
{{ default 42 "foo" }} → foo
{{ default 42 (dict "k" "v") }} → map[k:v]
{{ default 42 (slice "a" "b") }} → [a b]
{{ default 42 true }} → true
<!-- As noted above, the boolean "false" is considered set -->
{{ default 42 false }} → false
```
The `default` function returns the first argument if the second argument is not set:
```go-html-template
{{ default 42 0 }} → 42
{{ default 42 "" }} → 42
{{ default 42 dict }} → 42
{{ default 42 slice }} → 42
{{ default 42 <nil> }} → 42
```

View File

@@ -1,27 +0,0 @@
---
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...]']
aliases: [/functions/eq]
---
```go-html-template
{{ eq 1 1 }} → true
{{ eq 1 2 }} → false
{{ eq 1 1 1 }} → true
{{ eq 1 1 2 }} → true
{{ eq 1 2 1 }} → true
{{ eq 1 2 2 }} → false
```

View File

@@ -1,32 +0,0 @@
---
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...]']
aliases: [/functions/ge]
---
```go-html-template
{{ ge 1 1 }} → true
{{ ge 1 2 }} → false
{{ ge 2 1 }} → true
{{ ge 1 1 1 }} → true
{{ ge 1 1 2 }} → false
{{ ge 1 2 1 }} → false
{{ ge 1 2 2 }} → false
{{ ge 2 1 1 }} → true
{{ ge 2 1 2 }} → true
{{ ge 2 2 1 }} → true
```

View File

@@ -1,32 +0,0 @@
---
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...]']
aliases: [/functions/gt]
---
```go-html-template
{{ gt 1 1 }} → false
{{ gt 1 2 }} → false
{{ gt 2 1 }} → true
{{ gt 1 1 1 }} → false
{{ gt 1 1 2 }} → false
{{ gt 1 2 1 }} → false
{{ gt 1 2 2 }} → false
{{ gt 2 1 1 }} → true
{{ gt 2 1 2 }} → false
{{ gt 2 2 1 }} → false
```

View File

@@ -1,32 +0,0 @@
---
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...]']
aliases: [/functions/le]
---
```go-html-template
{{ le 1 1 }} → true
{{ le 1 2 }} → true
{{ le 2 1 }} → false
{{ le 1 1 1 }} → true
{{ le 1 1 2 }} → true
{{ le 1 2 1 }} → true
{{ le 1 2 2 }} → true
{{ le 2 1 1 }} → false
{{ le 2 1 2 }} → false
{{ le 2 2 1 }} → false
```

View File

@@ -1,32 +0,0 @@
---
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...]']
aliases: [/functions/lt]
---
```go-html-template
{{ lt 1 1 }} → false
{{ lt 1 2 }} → true
{{ lt 2 1 }} → false
{{ lt 1 1 1 }} → false
{{ lt 1 1 2 }} → false
{{ lt 1 2 1 }} → false
{{ lt 1 2 2 }} → true
{{ lt 2 1 1 }} → false
{{ lt 2 1 2 }} → false
{{ lt 2 2 1 }} → false
```

View File

@@ -1,27 +0,0 @@
---
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...]']
aliases: [/functions/ne]
---
```go-html-template
{{ ne 1 1 }} → false
{{ ne 1 2 }} → true
{{ ne 1 1 1 }} → false
{{ ne 1 1 2 }} → false
{{ ne 1 2 1 }} → false
{{ ne 1 2 2 }} → true
```

View File

@@ -1,12 +0,0 @@
---
title: Compare functions
linkTitle: compare
description: Template functions to compare two or more values.
categories: []
keywords: []
menu:
docs:
parent: functions
---
Use these functions to compare two or more values.