Site Lang Mood: {{ .Site.Language.Params.MOoD }}
Page Colors: {{ .Params.COLOR }}|{{ .Params.Colors.Blue }}
Site Colors: {{ .Site.Params.COLOR }}|{{ .Site.Params.COLORS.YELLOW }}
+{{ $page2 := .Site.GetPage "/sect2/page2" }}
+{{ if $page2 }}
+Page2: {{ $page2.Params.ColoR }}
+{{ end }}
{{ .Content }}
{{ partial "partial.html" . }}
`)
"Page Title: Side 1",
"Site Title: Nynorsk title",
"«Hi»", // angled quotes
+ "Page2: black ",
)
th.assertFileContent(filepath.Join("public", "en", "sect1", "page1", "index.html"),
content := readDestination(th, th.Fs, filename)
for _, match := range matches {
match = th.replaceDefaultContentLanguageValue(match)
- th.Assert(strings.Contains(content, match), qt.Equals, true)
+ th.Assert(strings.Contains(content, match), qt.Equals, true, qt.Commentf(content))
}
}
qt "github.com/frankban/quicktest"
)
+type paramsHolder struct {
+ params map[string]interface{}
+ page *paramsHolder
+}
+
+func (p paramsHolder) Params() map[string]interface{} {
+ return p.params
+}
+
+func (p paramsHolder) GetPage(arg string) *paramsHolder {
+ return p.page
+}
+
var (
testFuncs = map[string]interface{}{
"getif": func(v interface{}) interface{} { return v },
"ByWeight": fmt.Sprintf("%v:%v:%v", seq, key, args),
}, nil
},
- "site": func() interface{} {
- return map[string]interface{}{
- "Params": map[string]interface{}{
+ "site": func() paramsHolder {
+ return paramsHolder{
+ params: map[string]interface{}{
"lower": "global-site",
},
+ page: ¶msHolder{
+ params: map[string]interface{}{
+ "lower": "page",
+ },
+ },
}
},
}
paramsData = map[string]interface{}{
+
"NotParam": "Hi There",
"Slice": []int{1, 3},
"Params": map[string]interface{}{
},
},
},
+ "Site2": paramsHolder{
+ params: map[string]interface{}{
+ "lower": "global-site",
+ },
+ page: ¶msHolder{
+ params: map[string]interface{}{
+ "lower": "page",
+ },
+ },
+ },
}
paramsTempl = `
{{ $site := site }}
PARAMS SITE GLOBAL2: {{ $lower }}
PARAMS SITE GLOBAL3: {{ $site.Params.LOWER }}
+
+{{ $p := $site.GetPage "foo" }}
+PARAMS GETPAGE: {{ $p.Params.LOWER }}
+{{ $p := .Site2.GetPage "foo" }}
+PARAMS GETPAGE2: {{ $p.Params.LOWER }}
`
)
c.Assert(result, qt.Contains, "PARAMS SITE GLOBAL2: global-site")
c.Assert(result, qt.Contains, "PARAMS SITE GLOBAL3: global-site")
+ //
+ c.Assert(result, qt.Contains, "PARAMS GETPAGE: page")
+ c.Assert(result, qt.Contains, "PARAMS GETPAGE2: page")
+
}
func BenchmarkTemplateParamsKeysToLower(b *testing.B) {