summaryrefslogtreecommitdiffstats
path: root/docs/content/en/templates/introduction.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/templates/introduction.md')
-rw-r--r--docs/content/en/templates/introduction.md14
1 files changed, 13 insertions, 1 deletions
diff --git a/docs/content/en/templates/introduction.md b/docs/content/en/templates/introduction.md
index 1e1778eb0..02a580e79 100644
--- a/docs/content/en/templates/introduction.md
+++ b/docs/content/en/templates/introduction.md
@@ -20,7 +20,7 @@ toc: true
---
{{% note %}}
-The following is only a primer on Go Templates. For an in-depth look into Go Templates, check the official [Go docs](http://golang.org/pkg/html/template/).
+The following is only a primer on Go Templates. For an in-depth look into Go Templates, check the official [Go docs](https://golang.org/pkg/text/template/).
{{% /note %}}
Go Templates provide an extremely simple template language that adheres to the belief that only the most basic of logic belongs in the template or view layer.
@@ -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 }}`.