mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722'
This commit is contained in:
@@ -21,7 +21,7 @@ When the second argument is the boolean `false` value, the `default` function re
|
||||
|
||||
To set a default value based on truthiness, use the [`or`] operator instead.
|
||||
|
||||
[`or`]: /functions/go-template/or
|
||||
[`or`]: /functions/go-template/or/
|
||||
{{% /note %}}
|
||||
|
||||
The `default` function returns the second argument if set:
|
||||
|
@@ -25,3 +25,5 @@ aliases: [/functions/eq]
|
||||
{{ eq 1 2 1 }} → true
|
||||
{{ eq 1 2 2 }} → false
|
||||
```
|
||||
|
||||
You can also use the `compare.Eq` function to compare strings, boolean values, dates, slices, maps, and pages.
|
||||
|
@@ -30,3 +30,11 @@ aliases: [/functions/ge]
|
||||
{{ ge 2 1 2 }} → true
|
||||
{{ ge 2 2 1 }} → true
|
||||
```
|
||||
|
||||
Use the `compare.Ge` function to compare other data types as well:
|
||||
|
||||
```go-html-template
|
||||
{{ ge "ab" "a" }} → true
|
||||
{{ ge time.Now (time.AsTime "1964-12-30") }} → true
|
||||
{{ ge true false }} → true
|
||||
```
|
||||
|
@@ -30,3 +30,11 @@ aliases: [/functions/gt]
|
||||
{{ gt 2 1 2 }} → false
|
||||
{{ gt 2 2 1 }} → false
|
||||
```
|
||||
|
||||
Use the `compare.Gt` function to compare other data types as well:
|
||||
|
||||
```go-html-template
|
||||
{{ gt "ab" "a" }} → true
|
||||
{{ gt time.Now (time.AsTime "1964-12-30") }} → true
|
||||
{{ gt true false }} → true
|
||||
```
|
||||
|
@@ -30,3 +30,11 @@ aliases: [/functions/le]
|
||||
{{ le 2 1 2 }} → false
|
||||
{{ le 2 2 1 }} → false
|
||||
```
|
||||
|
||||
Use the `compare.Le` function to compare other data types as well:
|
||||
|
||||
```go-html-template
|
||||
{{ le "ab" "a" }} → false
|
||||
{{ le time.Now (time.AsTime "1964-12-30") }} → false
|
||||
{{ le true false }} → false
|
||||
```
|
||||
|
@@ -30,3 +30,11 @@ aliases: [/functions/lt]
|
||||
{{ lt 2 1 2 }} → false
|
||||
{{ lt 2 2 1 }} → false
|
||||
```
|
||||
|
||||
Use the `compare.Lt` function to compare other data types as well:
|
||||
|
||||
```go-html-template
|
||||
{{ lt "ab" "a" }} → false
|
||||
{{ lt time.Now (time.AsTime "1964-12-30") }} → false
|
||||
{{ lt true false }} → false
|
||||
```
|
||||
|
@@ -25,3 +25,5 @@ aliases: [/functions/ne]
|
||||
{{ ne 1 2 1 }} → false
|
||||
{{ ne 1 2 2 }} → true
|
||||
```
|
||||
|
||||
You can also use the `compare.Ne` function to compare strings, boolean values, dates, slices, maps, and pages.
|
||||
|
Reference in New Issue
Block a user