Add a test case for Go 1.16 template action newlines
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 3 Dec 2020 12:54:45 +0000 (13:54 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 18 Feb 2021 13:11:48 +0000 (14:11 +0100)
hugolib/template_test.go

index 769bcd4e6a8e0165d38b6df6ea3a6fb7ebe93cc7..265cea1cb83c25d8d5f3f75355a12b3137e7828b 100644 (file)
@@ -584,6 +584,22 @@ func TestTemplateGoIssues(t *testing.T) {
                "index.html", `
 {{ $title := "a & b" }}
 <script type="application/ld+json">{"@type":"WebPage","headline":"{{$title}}"}</script>
+
+{{/* Action newlines, from Go 1.16, see https://github.com/golang/go/issues/29770 */}}
+{{ $norway := dict
+       "country" "Norway"
+       "population" "5 millions"
+       "language" "Norwegian"
+       "language_code" "nb"
+       "weather" "freezing cold"
+       "capitol" "Oslo"
+       "largest_city" "Oslo"
+       "currency"  "Norwegian krone"
+       "dialing_code" "+47"
+}}
+
+Population in Norway is {{ $norway.population }}
+
 `,
        )
 
@@ -591,6 +607,7 @@ func TestTemplateGoIssues(t *testing.T) {
 
        b.AssertFileContent("public/index.html", `
 <script type="application/ld+json">{"@type":"WebPage","headline":"a \u0026 b"}</script>
+Population in Norway is 5 millions
 
 `)
 }