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>2020-07-01 11:43:17 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-07-02 00:10:21 +0300
commit4a3efea7efe59cd3de7d0eb352836ab395a2b6b3 (patch)
tree99185f7c06113125ea474af365dcb32f356d68ed /docs/content/en/templates
parentc66dc6c74fa3bbe308ccaade8c76071b49908129 (diff)
Add support for inline partials
Fixes #7444
Diffstat (limited to 'docs/content/en/templates')
-rw-r--r--docs/content/en/templates/partials.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/content/en/templates/partials.md b/docs/content/en/templates/partials.md
index 873f5e696..d23622ded 100644
--- a/docs/content/en/templates/partials.md
+++ b/docs/content/en/templates/partials.md
@@ -81,6 +81,21 @@ This means the partial will *only* be able to access those variables. The partia
In addition to outputting markup, partials can be used to return a value of any type. In order to return a value, a partial must include a lone `return` statement.
+## Inline partials
+
+{{< new-in "0.74.0" >}}
+
+You can also define partials inline in the template. But remember that template namespace is global, so you need to make sure that the names are unique to avoid conflicts.
+
+```go-html-template
+Value: {{ partial "my-inline-partial" . }}
+
+{{ define "partials/my-inline-partial" }}
+{{ $value := 32 }}
+{{ return $value }}
+{{ end }}
+```
+
### Example GetFeatured
```go-html-template
{{/* layouts/partials/GetFeatured.html */}}