tpl: Allow the partial template func to return any type
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 2 Apr 2019 08:30:24 +0000 (10:30 +0200)
committerGitHub <noreply@github.com>
Tue, 2 Apr 2019 08:30:24 +0000 (10:30 +0200)
commita55640de8e3944d3b9f64b15155148a0e35cb31e
tree3fe07277c5f7f675571c15851ce9fdc96a2bcecd
parent9225db636e2f9b75f992013a25c0b149d6bd8b0d
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
compare/compare.go
hugolib/template_test.go
metrics/metrics.go
tpl/partials/init.go
tpl/partials/partials.go
tpl/template_info.go
tpl/tplimpl/ace.go
tpl/tplimpl/shortcodes.go
tpl/tplimpl/template.go
tpl/tplimpl/template_ast_transformers.go
tpl/tplimpl/template_ast_transformers_test.go