mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
@@ -38,7 +38,6 @@ import (
|
||||
"github.com/gohugoio/hugo/tpl"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/common/types"
|
||||
|
||||
"github.com/gohugoio/hugo/source"
|
||||
@@ -149,7 +148,7 @@ func (p *pageState) Key() string {
|
||||
}
|
||||
|
||||
func (p *pageState) resetBuildState() {
|
||||
p.Scratcher = maps.NewScratcher()
|
||||
// Nothing to do for now.
|
||||
}
|
||||
|
||||
func (p *pageState) reusePageOutputContent() bool {
|
||||
|
@@ -56,7 +56,6 @@ type pageCommon struct {
|
||||
store *maps.Scratch
|
||||
|
||||
// All of these represents the common parts of a page.Page
|
||||
maps.Scratcher
|
||||
navigation.PageMenusProvider
|
||||
page.AuthorProvider
|
||||
page.AlternativeOutputFormatsProvider
|
||||
@@ -113,3 +112,8 @@ type pageCommon struct {
|
||||
func (p *pageCommon) Store() *maps.Scratch {
|
||||
return p.store
|
||||
}
|
||||
|
||||
// See issue 13016.
|
||||
func (p *pageCommon) Scratch() *maps.Scratch {
|
||||
return p.Store()
|
||||
}
|
||||
|
@@ -184,7 +184,6 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
|
||||
pageCommon: &pageCommon{
|
||||
FileProvider: m,
|
||||
AuthorProvider: m,
|
||||
Scratcher: maps.NewScratcher(),
|
||||
store: maps.NewScratch(),
|
||||
Positioner: page.NopPage,
|
||||
InSectionPositioner: page.NopPage,
|
||||
|
@@ -1688,6 +1688,32 @@ title: Scratch Me!
|
||||
b.AssertFileContent("public/scratchme/index.html", "C: cv")
|
||||
}
|
||||
|
||||
// Issue 13016.
|
||||
func TestScratchAliasToStore(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ["taxonomy", "term", "page", "section"]
|
||||
disableLiveReload = true
|
||||
-- layouts/index.html --
|
||||
{{ .Scratch.Set "a" "b" }}
|
||||
{{ .Store.Set "c" "d" }}
|
||||
.Scratch eq .Store: {{ eq .Scratch .Store }}
|
||||
a: {{ .Store.Get "a" }}
|
||||
c: {{ .Scratch.Get "c" }}
|
||||
|
||||
`
|
||||
|
||||
b := Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html",
|
||||
".Scratch eq .Store: true",
|
||||
"a: b",
|
||||
"c: d",
|
||||
)
|
||||
}
|
||||
|
||||
func TestPageParam(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
Reference in New Issue
Block a user