mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
tpl: Allow the partial template func to return any type
This commit adds support for return values in partials. This means that you can now do this and similar: {{ $v := add . 42 }} {{ return $v }} Partials without a `return` statement will be rendered as before. This works for both `partial` and `partialCached`. Fixes #5783
This commit is contained in:
committed by
GitHub
parent
9225db636e
commit
a55640de8e
@@ -139,6 +139,18 @@ func templateNameAndVariants(name string) (string, []string) {
|
||||
return name, variants
|
||||
}
|
||||
|
||||
func resolveTemplateType(name string) templateType {
|
||||
if isShortcode(name) {
|
||||
return templateShortcode
|
||||
}
|
||||
|
||||
if strings.Contains(name, "partials/") {
|
||||
return templatePartial
|
||||
}
|
||||
|
||||
return templateUndefined
|
||||
}
|
||||
|
||||
func isShortcode(name string) bool {
|
||||
return strings.Contains(name, "shortcodes/")
|
||||
}
|
||||
|
Reference in New Issue
Block a user