diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-07-28 13:31:32 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-07-28 14:03:12 +0300 |
commit | e393c6290e827111a8a2e486791dc21f63a92b55 (patch) | |
tree | 60675fcabe21cb2aaee98625e2fad4bd53fa5afa /hugolib | |
parent | 93d02aabe6e611d65c428a9c5669b422e1bcf5e8 (diff) |
common/maps: Do not return error on params dot access on incompatible types
This error was introduced in 0.56 and has shown some site breakage in the wild.
Fixes #6121
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/page_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go index e754a5e4f..3a0a76c3d 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -1543,3 +1543,58 @@ title: Scratch Me! b.AssertFileContent("public/index.html", "B: bv") b.AssertFileContent("public/scratchme/index.html", "C: cv") } + +func TestPageParam(t *testing.T) { + t.Parallel() + + b := newTestSitesBuilder(t).WithConfigFile("toml", ` + +baseURL = "https://example.org" + +[params] +[params.author] + name = "Kurt Vonnegut" + +`) + b.WithTemplatesAdded("index.html", ` + +{{ $withParam := .Site.GetPage "withparam" }} +{{ $noParam := .Site.GetPage "noparam" }} +{{ $withStringParam := .Site.GetPage "withstringparam" }} + +Author page: {{ $withParam.Param "author.name" }} +Author page string: {{ $withStringParam.Param "author.name" }}| +Author site config: {{ $noParam.Param "author.name" }} + +`, + ) + + b.WithContent("withparam.md", ` ++++ +title = "With Param!" +[author] + name = "Ernest Miller Hemingway" + ++++ + +`, + + "noparam.md", ` +--- +title: "No Param!" +--- +`, "withstringparam.md", ` ++++ +title = "With string Param!" +author = "Jo Nesbø" + ++++ + +`) + b.Build(BuildCfg{}) + + b.AssertFileContent("public/index.html", "Author page: Ernest Miller Hemingway") + b.AssertFileContent("public/index.html", "Author page string: |") + b.AssertFileContent("public/index.html", "Author site config: Kurt Vonnegut") + +} |