mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Merge commit 'dec8cd4ada29218971743333f8ac662a9c06aad8'
This commit is contained in:
@@ -2,4 +2,6 @@
|
||||
# Do not remove front matter.
|
||||
---
|
||||
|
||||
In Go templates, the falsy values are `false`, `0`, any nil pointer or interface value, and any array, slice, map, or string of length zero. Everything else is truthy.
|
||||
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.
|
||||
|
@@ -34,7 +34,7 @@ Use with the [`else`] statement:
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Use `else if` to check multiple conditions.
|
||||
Use `else if` to check multiple conditions:
|
||||
|
||||
```go-html-template
|
||||
{{ $var := 12 }}
|
||||
|
@@ -36,6 +36,20 @@ Use with the [`else`] statement:
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Use `else with` to check multiple conditions:
|
||||
|
||||
```go-html-template
|
||||
{{ $v1 := 0 }}
|
||||
{{ $v2 := 42 }}
|
||||
{{ with $v1 }}
|
||||
{{ . }}
|
||||
{{ else with $v2 }}
|
||||
{{ . }} → 42
|
||||
{{ else }}
|
||||
{{ print "v1 and v2 are falsy" }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
Initialize a variable, scoped to the current block:
|
||||
|
||||
```go-html-template
|
||||
|
Reference in New Issue
Block a user