diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-08-28 17:35:33 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-08-28 17:35:33 +0200 |
commit | 0c8a4154838e32a33d34202fd4fa0187aa502190 (patch) | |
tree | ec5e08b1a1069ff50109b8f09bcc0cbf98d7f7bc /hugolib/resource_chain_test.go | |
parent | f4675fa0f0fae2358adfaea49e8da824ee094495 (diff) |
hugolib: Add a test for template variable overwrite
New in Go 1.11.
Diffstat (limited to 'hugolib/resource_chain_test.go')
-rw-r--r-- | hugolib/resource_chain_test.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go index ad0d9611c..9e8991d8d 100644 --- a/hugolib/resource_chain_test.go +++ b/hugolib/resource_chain_test.go @@ -259,13 +259,17 @@ T2: Content: {{ $combinedText.Content }}|{{ $combinedText.RelPermalink }} }}, {"execute-as-template", func() bool { return true }, func(b *sitesBuilder) { b.WithTemplates("home.html", ` - +{{ $var := "Hugo Page" }} +{{ if .IsHome }} +{{ $var = "Hugo Home" }} +{{ end }} +T1: {{ $var }} {{ $result := "{{ .Kind | upper }}" | resources.FromString "mytpl.txt" | resources.ExecuteAsTemplate "result.txt" . }} -T1: {{ $result.Content }}|{{ $result.RelPermalink}}|{{$result.MediaType.Type }} +T2: {{ $result.Content }}|{{ $result.RelPermalink}}|{{$result.MediaType.Type }} `) }, func(b *sitesBuilder) { - b.AssertFileContent("public/index.html", `T1: HOME|/result.txt|text/plain`) + b.AssertFileContent("public/index.html", `T2: HOME|/result.txt|text/plain`, `T1: Hugo Home`) }}, {"fingerprint", func() bool { return true }, func(b *sitesBuilder) { |