diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-04-02 10:30:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 10:30:24 +0200 |
commit | a55640de8e3944d3b9f64b15155148a0e35cb31e (patch) | |
tree | 3fe07277c5f7f675571c15851ce9fdc96a2bcecd /tpl/template_info.go | |
parent | 9225db636e2f9b75f992013a25c0b149d6bd8b0d (diff) |
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
Diffstat (limited to 'tpl/template_info.go')
-rw-r--r-- | tpl/template_info.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tpl/template_info.go b/tpl/template_info.go index 8568f46f0..be0566958 100644 --- a/tpl/template_info.go +++ b/tpl/template_info.go @@ -22,10 +22,17 @@ type Info struct { // Set for shortcode templates with any {{ .Inner }} IsInner bool + // Set for partials with a return statement. + HasReturn bool + // Config extracted from template. Config Config } +func (info Info) IsZero() bool { + return info.Config.Version == 0 +} + type Config struct { Version int } |