mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-31 22:41:53 +02:00
Fix server rebuild issue with partials referenced from render hooks
Fixes #7990
This commit is contained in:
@@ -20,6 +20,43 @@ import (
|
||||
qt "github.com/frankban/quicktest"
|
||||
)
|
||||
|
||||
func TestRenderHookEditNestedPartial(t *testing.T) {
|
||||
config := `
|
||||
baseURL="https://example.org"
|
||||
workingDir="/mywork"
|
||||
`
|
||||
b := newTestSitesBuilder(t).WithWorkingDir("/mywork").WithConfigFile("toml", config).Running()
|
||||
|
||||
b.WithTemplates("_default/single.html", "{{ .Content }}")
|
||||
b.WithTemplates("partials/mypartial1.html", `PARTIAL1 {{ partial "mypartial2.html" }}`)
|
||||
b.WithTemplates("partials/mypartial2.html", `PARTIAL2`)
|
||||
b.WithTemplates("_default/_markup/render-link.html", `Link {{ .Text | safeHTML }}|{{ partial "mypartial1.html" . }}END`)
|
||||
|
||||
b.WithContent("p1.md", `---
|
||||
title: P1
|
||||
---
|
||||
|
||||
[First Link](https://www.google.com "Google's Homepage")
|
||||
|
||||
`)
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", `Link First Link|PARTIAL1 PARTIAL2END`)
|
||||
|
||||
b.EditFiles("layouts/partials/mypartial1.html", `PARTIAL1_EDITED {{ partial "mypartial2.html" }}`)
|
||||
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", `Link First Link|PARTIAL1_EDITED PARTIAL2END`)
|
||||
|
||||
b.EditFiles("layouts/partials/mypartial2.html", `PARTIAL2_EDITED`)
|
||||
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/p1/index.html", `Link First Link|PARTIAL1_EDITED PARTIAL2_EDITEDEND`)
|
||||
|
||||
}
|
||||
|
||||
func TestRenderHooks(t *testing.T) {
|
||||
config := `
|
||||
baseURL="https://example.org"
|
||||
|
@@ -409,7 +409,7 @@ func (p *pageState) createRenderHooks(f output.Format) (*hooks.Renderers, error)
|
||||
if templFound {
|
||||
renderers.LinkRenderer = hookRenderer{
|
||||
templateHandler: p.s.Tmpl(),
|
||||
Provider: templ.(tpl.Info),
|
||||
SearchProvider: templ.(identity.SearchProvider),
|
||||
templ: templ,
|
||||
}
|
||||
}
|
||||
@@ -422,7 +422,7 @@ func (p *pageState) createRenderHooks(f output.Format) (*hooks.Renderers, error)
|
||||
if templFound {
|
||||
renderers.ImageRenderer = hookRenderer{
|
||||
templateHandler: p.s.Tmpl(),
|
||||
Provider: templ.(tpl.Info),
|
||||
SearchProvider: templ.(identity.SearchProvider),
|
||||
templ: templ,
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ func (p *pageState) createRenderHooks(f output.Format) (*hooks.Renderers, error)
|
||||
if templFound {
|
||||
renderers.HeadingRenderer = hookRenderer{
|
||||
templateHandler: p.s.Tmpl(),
|
||||
Provider: templ.(tpl.Info),
|
||||
SearchProvider: templ.(identity.SearchProvider),
|
||||
templ: templ,
|
||||
}
|
||||
}
|
||||
|
@@ -1738,7 +1738,7 @@ var infoOnMissingLayout = map[string]bool{
|
||||
// where ITEM is the thing being hooked.
|
||||
type hookRenderer struct {
|
||||
templateHandler tpl.TemplateHandler
|
||||
identity.Provider
|
||||
identity.SearchProvider
|
||||
templ tpl.Template
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user