mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
@@ -1893,3 +1893,52 @@ func TestRenderWithoutArgument(t *testing.T) {
|
||||
|
||||
b.Assert(err, qt.IsNotNil)
|
||||
}
|
||||
|
||||
// Issue #13021
|
||||
func TestAllStores(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ["taxonomy", "term", "page", "section"]
|
||||
disableLiveReload = true
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: "Home"
|
||||
---
|
||||
{{< s >}}
|
||||
-- layouts/shortcodes/s.html --
|
||||
{{ if not (.Store.Get "Shortcode") }}{{ .Store.Set "Shortcode" (printf "sh-%s" $.Page.Title) }}{{ end }}
|
||||
Shortcode: {{ .Store.Get "Shortcode" }}|
|
||||
-- layouts/index.html --
|
||||
{{ .Content }}
|
||||
{{ if not (.Store.Get "Page") }}{{ .Store.Set "Page" (printf "p-%s" $.Title) }}{{ end }}
|
||||
{{ if not (hugo.Store.Get "Hugo") }}{{ hugo.Store.Set "Hugo" (printf "h-%s" $.Title) }}{{ end }}
|
||||
{{ if not (site.Store.Get "Site") }}{{ site.Store.Set "Site" (printf "s-%s" $.Title) }}{{ end }}
|
||||
Page: {{ .Store.Get "Page" }}|
|
||||
Hugo: {{ hugo.Store.Get "Hugo" }}|
|
||||
Site: {{ site.Store.Get "Site" }}|
|
||||
`
|
||||
|
||||
b := TestRunning(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html",
|
||||
`
|
||||
Shortcode: sh-Home|
|
||||
Page: p-Home|
|
||||
Site: s-Home|
|
||||
Hugo: h-Home|
|
||||
`,
|
||||
)
|
||||
|
||||
b.EditFileReplaceAll("content/_index.md", "Home", "Homer").Build()
|
||||
|
||||
b.AssertFileContent("public/index.html",
|
||||
`
|
||||
Shortcode: sh-Homer|
|
||||
Page: p-Homer|
|
||||
Site: s-Home|
|
||||
Hugo: h-Home|
|
||||
`,
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user