summaryrefslogtreecommitdiffstats
path: root/tpl/collections/integration_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/collections/integration_test.go')
-rw-r--r--tpl/collections/integration_test.go60
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 &lt;nil&gt;]")
+
+ }
+
+}
+
+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 &lt;nil&gt; c &lt;nil&gt;]")
+
+ }
+
+}