mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-13 13:03:00 +00:00
Merge b856d60b81
into 74ce5dc841
This commit is contained in:
commit
f90d1f1f15
|
@ -1558,3 +1558,60 @@ title: "P1 us"
|
||||||
`
|
`
|
||||||
Test(t, files)
|
Test(t, files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBaseSignalChildParent(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
-- content/_index.md --
|
||||||
|
-- content/p1.md --
|
||||||
|
-- layouts/_default/baseof.html --
|
||||||
|
{{ block "_baseof_start" . }}{{ end }}
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
{{/* Lots of imports of SEO partials, stylesheets, JS and whatnot. */}}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ $flow := .Store.Get "_baseof_flow" | default "default" }}
|
||||||
|
{{ if eq $flow "default" }}
|
||||||
|
<div>
|
||||||
|
<h1>Default flow</h1>
|
||||||
|
{{ block "main" . }}{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ else if eq $flow "foo" }}
|
||||||
|
<div>
|
||||||
|
<h1>Foo flow</h1>
|
||||||
|
{{ block "main" . }}{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ else if eq $flow "bar" }}
|
||||||
|
<div>
|
||||||
|
<h1>Bar flow</h1>
|
||||||
|
{{ block "main" . }}{{ end }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
-- layouts/index.html --
|
||||||
|
{{ define "_baseof_start" }}{{ .Page.Store.Set "_baseof_flow" "foo" }}{{ end }}
|
||||||
|
{{ define "main" }}Main Home{{ end }}
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
{{ define "_baseof_start" }}{{ .Page.Store.Set "_baseof_flow" "bar" }}{{ end }}
|
||||||
|
{{ define "main" }}Main Single{{ end }}
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
b := NewIntegrationTestBuilder(
|
||||||
|
IntegrationTestConfig{
|
||||||
|
T: t,
|
||||||
|
TxtarString: files,
|
||||||
|
},
|
||||||
|
).Build()
|
||||||
|
|
||||||
|
b.AssertFileContent("public/index.html", `
|
||||||
|
Foo flow
|
||||||
|
Main Home
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue