diff options
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/collections/integration_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tpl/collections/integration_test.go b/tpl/collections/integration_test.go index da1d6e488..829aee355 100644 --- a/tpl/collections/integration_test.go +++ b/tpl/collections/integration_test.go @@ -104,3 +104,63 @@ func TestAppendSliceToASliceOfSlices(t *testing.T) { } } + +func TestAppendNilToSlice(t *testing.T) { + + t.Parallel() + + files := ` +-- hugo.toml -- +-- layouts/index.html -- +{{ $obj := (slice "a") }} +{{ $obj = $obj | append nil }} + +{{ $obj }} + + + ` + + for i := 0; i < 4; i++ { + + b := hugolib.NewIntegrationTestBuilder( + hugolib.IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/index.html", "[a <nil>]") + + } + +} + +func TestAppendNilsToSliceWithNils(t *testing.T) { + + t.Parallel() + + files := ` +-- hugo.toml -- +-- layouts/index.html -- +{{ $obj := (slice "a" nil "c") }} +{{ $obj = $obj | append nil }} + +{{ $obj }} + + + ` + + for i := 0; i < 4; i++ { + + b := hugolib.NewIntegrationTestBuilder( + hugolib.IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/index.html", "[a <nil> c <nil>]") + + } + +} |