Allow for return partials with falsy arguments (#9298)
authorPaul Gottschling <paul.gottschling@gmail.com>
Fri, 17 Dec 2021 07:35:21 +0000 (02:35 -0500)
committerGitHub <noreply@github.com>
Fri, 17 Dec 2021 07:35:21 +0000 (08:35 +0100)
commit5758c370eac6c4460cd6bb34d4475c8d347585f6
tree8a9f337cf38ed842a1d011f46d43f0e58768fd5a
parent8ee6de6d96a64395d27416d4f2ad7d172a2686d0
Allow for return partials with falsy arguments (#9298)

Partials with returns values are parsed, then inserted into a
partial return wrapper via wrapInPartialReturnWrapper in order
to assign the return value via *contextWrapper.Set. The
predefined wrapper template for partials inserts a partial's nodes
into a "with" template action in order to set dot to a
*contextWrapper within the partial. However, because "with" is
skipped if its argument is falsy, partials with falsy arguments
were not being evaluated.

This replaces the "with" action in the partial wrapper with a
"range" action that isn't skipped if .Arg is falsy.

Fixes #7528
hugolib/template_test.go
tpl/partials/partials.go
tpl/tplimpl/template_ast_transformers.go