Merge commit 'dec8cd4ada29218971743333f8ac662a9c06aad8'

This commit is contained in:
Bjørn Erik Pedersen
2024-09-01 14:51:15 +02:00
43 changed files with 906 additions and 436 deletions

View File

@@ -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.

View File

@@ -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 }}

View File

@@ -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