mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +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
@@ -36,6 +36,13 @@ func init() {
|
||||
},
|
||||
)
|
||||
|
||||
// TODO(bep) we need the return to be a valid identifier, but
|
||||
// should consider another way of adding it.
|
||||
ns.AddMethodMapping(func() string { return "" },
|
||||
[]string{"return"},
|
||||
[][2]string{},
|
||||
)
|
||||
|
||||
ns.AddMethodMapping(ctx.IncludeCached,
|
||||
[]string{"partialCached"},
|
||||
[][2]string{},
|
||||
|
Reference in New Issue
Block a user