summaryrefslogtreecommitdiffstats
path: root/hugolib/case_insensitive_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-21 21:59:38 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-22 18:41:50 +0100
commita3fe5e5e35f311f22b6b4fc38abfcf64cd2c7d6f (patch)
tree06cf1f647ae026b4fb3053c85370c2b203c7a089 /hugolib/case_insensitive_test.go
parentcd07e6d57b158a76f812e8c4c9567dbc84f57939 (diff)
Fix Params case handling in the index, sort and where func
This means that you can now do: ``` {{ range where .Site.Pages "Params.MYPARAM" "foo" }} ```
Diffstat (limited to 'hugolib/case_insensitive_test.go')
-rw-r--r--hugolib/case_insensitive_test.go36
1 files changed, 19 insertions, 17 deletions
diff --git a/hugolib/case_insensitive_test.go b/hugolib/case_insensitive_test.go
index 5c7dbe073..9c2662044 100644
--- a/hugolib/case_insensitive_test.go
+++ b/hugolib/case_insensitive_test.go
@@ -61,7 +61,7 @@ angledQuotes = false
hrefTargetBlank = false
[Languages.en.Colors]
BLUE = "blues"
-yellow = "golden"
+Yellow = "golden"
`
caseMixingPage1En = `
---
@@ -137,18 +137,6 @@ func TestCaseInsensitiveConfigurationVariations(t *testing.T) {
c := qt.New(t)
- // See issues 2615, 1129, 2590 and maybe some others
- // Also see 2598
- //
- // Viper is now, at least for the Hugo part, case insensitive
- // So we need tests for all of it, with needed adjustments on the Hugo side.
- // Not sure what that will be. Let us see.
-
- // So all the below with case variations:
- // config: regular fields, blackfriday config, param with nested map
- // language: new and overridden values, in regular fields and nested paramsmap
- // page frontmatter: regular fields, blackfriday config, param with nested map
-
mm := afero.NewMemMapFs()
caseMixingTestsWriteCommonSources(t, mm)
@@ -168,17 +156,27 @@ Block Page Colors: {{ .Params.COLOR }}|{{ .Params.Colors.Blue }}
{{ define "main"}}
Page Colors: {{ .Params.CoLOR }}|{{ .Params.Colors.Blue }}
Site Colors: {{ .Site.Params.COlOR }}|{{ .Site.Params.COLORS.YELLOW }}
+{{ template "index-color" (dict "name" "Page" "params" .Params) }}
+{{ template "index-color" (dict "name" "Site" "params" .Site.Params) }}
+
{{ .Content }}
{{ partial "partial.html" . }}
{{ end }}
+{{ define "index-color" }}
+{{ $yellow := index .params "COLoRS" "yELLOW" }}
+{{ $colors := index .params "COLoRS" }}
+{{ $yellow2 := index $colors "yEllow" }}
+index1|{{ .name }}: {{ $yellow }}|
+index2|{{ .name }}: {{ $yellow2 }}|
+{{ end }}
`)
writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), `
Page Title: {{ .Title }}
Site Title: {{ .Site.Title }}
Site Lang Mood: {{ .Site.Language.Params.MOoD }}
-Page Colors: {{ .Params.COLOR }}|{{ .Params.Colors.Blue }}
-Site Colors: {{ .Site.Params.COLOR }}|{{ .Site.Params.COLORS.YELLOW }}
+Page Colors: {{ .Params.COLOR }}|{{ .Params.Colors.Blue }}|{{ index .Params "ColOR" }}
+Site Colors: {{ .Site.Params.COLOR }}|{{ .Site.Params.COLORS.YELLOW }}|{{ index .Site.Params "ColOR" }}
{{ $page2 := .Site.GetPage "/sect2/page2" }}
{{ if $page2 }}
Page2: {{ $page2.Params.ColoR }}
@@ -200,8 +198,8 @@ Page2: {{ $page2.Params.ColoR }}
}
th.assertFileContent(filepath.Join("public", "nn", "sect1", "page1", "index.html"),
- "Page Colors: red|heavenly",
- "Site Colors: green|yellow",
+ "Page Colors: red|heavenly|red",
+ "Site Colors: green|yellow|green",
"Site Lang Mood: Happy",
"Shortcode Page: red|heavenly",
"Shortcode Site: green|yellow",
@@ -230,6 +228,10 @@ Page2: {{ $page2.Params.ColoR }}
"Block Page Colors: black|sky",
"Partial Page: black|sky",
"Partial Site: green|yellow",
+ "index1|Page: flower|",
+ "index1|Site: yellow|",
+ "index2|Page: flower|",
+ "index2|Site: yellow|",
)
}