Fix RenderString for pages without content

Fixes #6882
This commit is contained in:
Bjørn Erik Pedersen 2020-02-18 14:00:58 +01:00
parent 20f2211fce
commit 19e12caf8c
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
4 changed files with 62 additions and 13 deletions

View file

@ -372,3 +372,30 @@ RSTART:<em>italic org mode</em>:REND
`)
}
// https://github.com/gohugoio/hugo/issues/6882
func TestRenderStringOnListPage(t *testing.T) {
renderStringTempl := `
{{ .RenderString "**Hello**" }}
`
b := newTestSitesBuilder(t)
b.WithContent("mysection/p1.md", `FOO`)
b.WithTemplates(
"index.html", renderStringTempl,
"_default/list.html", renderStringTempl,
"_default/single.html", renderStringTempl,
)
b.Build(BuildCfg{})
for _, filename := range []string{
"index.html",
"mysection/index.html",
"categories/index.html",
"tags/index.html",
"mysection/p1/index.html",
} {
b.AssertFileContent("public/"+filename, `<strong>Hello</strong>`)
}
}