Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-25 11:41:51 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-25 11:41:51 +0300
commit4f61a926f61b490ed9ddf8de276bc355448c5a86 (patch)
treef928ce54970e79e425364905cfde36218134b75d /docs/content/en/templates
parent5b4b8bb3c1ecb30e7a38ed44eb795f1d972cd320 (diff)
parentbe04ece8590f775a52ea167fbe4555753e8c5211 (diff)
Merge commit 'be04ece8590f775a52ea167fbe4555753e8c5211'
Diffstat (limited to 'docs/content/en/templates')
-rw-r--r--docs/content/en/templates/404.md1
-rw-r--r--docs/content/en/templates/introduction.md14
2 files changed, 14 insertions, 1 deletions
diff --git a/docs/content/en/templates/404.md b/docs/content/en/templates/404.md
index c6bea1912..bb1d5e424 100644
--- a/docs/content/en/templates/404.md
+++ b/docs/content/en/templates/404.md
@@ -52,6 +52,7 @@ Your 404.html file can be set to load automatically when a visitor enters a mist
* Amazon AWS S3. When setting a bucket up for static web serving, you can specify the error file from within the S3 GUI.
* Amazon CloudFont. You can specify the page in the Error Pages section in the CloudFont Console. [Details here](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html)
* Caddy Server. Using `errors { 404 /404.html }`. [Details here](https://caddyserver.com/docs/errors)
+* Netlify. Add `/* /404.html 404` to `content/_redirects`. [Details Here](https://www.netlify.com/docs/redirects/#custom-404)
{{% note %}}
`hugo server` will not automatically load your custom `404.html` file, but you
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 }}`.