mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 06:17:45 +00:00
1 parent
efe0e549c5
commit
d71ed99d3b
1 file changed
+15
@@ -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.
|
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
|
### Example GetFeatured
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{/* layouts/partials/GetFeatured.html */}}
|
{{/* layouts/partials/GetFeatured.html */}}
|
||||||
|
|||||||
Reference in new issue
Block a user