mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-13 08:38:04 -04:00
parent
b14dd35053
commit
0c3c04fd63
@ -233,6 +233,18 @@ key.
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
#### Example 5: Conditional on empty _map_, _array_, or _slice_.
|
||||
|
||||
If the _map_, _array_, or _slice_ passed into the range is zero-length then the else statment is evaluated.
|
||||
|
||||
```go-html-template
|
||||
{{ range $array }}
|
||||
{{ . }}
|
||||
{{else}}
|
||||
<!-- This is only evaluated if $array is empty -->
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
### Conditionals
|
||||
|
||||
`if`, `else`, `with`, `or`, and `and` provide the framework for handling conditional logic in Go Templates. Like `range`, each statement is closed with an `{{ end }}`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user