mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 12:12:10 -05:00
Fix rebuild logic when editing template using a base template
We have been doing too much work in that case. Fixes #6968
This commit is contained in:
parent
b66d38c419
commit
b0d850321e
2 changed files with 31 additions and 0 deletions
|
@ -15,6 +15,8 @@ package hugolib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
qt "github.com/frankban/quicktest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSitesRebuild(t *testing.T) {
|
func TestSitesRebuild(t *testing.T) {
|
||||||
|
@ -142,6 +144,29 @@ Data Inline: Rules!`)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// https://github.com/gohugoio/hugo/issues/6968
|
||||||
|
t.Run("Edit single.html with base", func(t *testing.T) {
|
||||||
|
b := newTestSitesBuilder(t).Running()
|
||||||
|
|
||||||
|
b.WithTemplates(
|
||||||
|
"_default/single.html", `{{ define "main" }}Single{{ end }}`,
|
||||||
|
"_default/baseof.html", `Base: {{ block "main" .}}Block{{ end }}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
b.WithContent("p1.md", "---\ntitle: Page\n---")
|
||||||
|
|
||||||
|
b.Build(BuildCfg{})
|
||||||
|
|
||||||
|
b.EditFiles("layouts/_default/single.html", `Single Edit: {{ define "main" }}Single{{ end }}`)
|
||||||
|
|
||||||
|
counters := &testCounters{}
|
||||||
|
|
||||||
|
b.Build(BuildCfg{testCounters: counters})
|
||||||
|
|
||||||
|
b.Assert(int(counters.contentRenderCounter), qt.Equals, 0)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Page.Render, edit baseof", func(t *testing.T) {
|
t.Run("Page.Render, edit baseof", func(t *testing.T) {
|
||||||
b := createSiteBuilder(t)
|
b := createSiteBuilder(t)
|
||||||
|
|
||||||
|
|
|
@ -383,9 +383,15 @@ func (t *templateHandler) LookupVariant(name string, variants tpl.TemplateVarian
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *templateHandler) HasTemplate(name string) bool {
|
func (t *templateHandler) HasTemplate(name string) bool {
|
||||||
|
|
||||||
if _, found := t.baseof[name]; found {
|
if _, found := t.baseof[name]; found {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, found := t.needsBaseof[name]; found {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
_, found := t.Lookup(name)
|
_, found := t.Lookup(name)
|
||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue