mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-29 01:32:37 +00:00
Add examples to comparison operators
This commit is contained in:
@@ -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