diff options
Diffstat (limited to 'content/en/functions/go-template/with.md')
-rw-r--r-- | content/en/functions/go-template/with.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/content/en/functions/go-template/with.md b/content/en/functions/go-template/with.md index 3a73d54bb..3d628e28d 100644 --- a/content/en/functions/go-template/with.md +++ b/content/en/functions/go-template/with.md @@ -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 |