diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-01-17 00:01:13 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-01-17 11:50:48 +0300 |
commit | 2655739940d8148ef374248e867b44d87cd63edf (patch) | |
tree | 80feed083fac1525d8571dd0aa87c4d304b19c7a /hugolib | |
parent | 348d300a719ae5528997758ebf552691842839b3 (diff) |
tpl/collections: Fix apply with namespaced template funcs
We changed the signature to `func(...interface{}) (interface{}, error)` some time ago, but sadly we had no test for this for `apply`. Now we do.
Fixes #9393
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/template_test.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/hugolib/template_test.go b/hugolib/template_test.go index 2908fdf71..f9d54d8dc 100644 --- a/hugolib/template_test.go +++ b/hugolib/template_test.go @@ -460,7 +460,6 @@ complex: 80: 80 // Issue 7528 func TestPartialWithZeroedArgs(t *testing.T) { - b := newTestSitesBuilder(t) b.WithTemplatesAdded("index.html", ` @@ -483,7 +482,6 @@ X123X X123X X123X `) - } func TestPartialCached(t *testing.T) { @@ -757,3 +755,20 @@ This is single main `, ) } + +// Issue 9393. +func TestApplyWithNamespace(t *testing.T) { + b := newTestSitesBuilder(t) + + b.WithTemplates( + "index.html", ` +{{ $b := slice " a " " b " " c" }} +{{ $a := apply $b "strings.Trim" "." " " }} +a: {{ $a }} +`, + ).WithContent("p1.md", "") + + b.Build(BuildCfg{}) + + b.AssertFileContent("public/index.html", `a: [a b c]`) +} |