Fix .RenderString issue in .Translations

Fixes #9383
This commit is contained in:
Paul Gottschling
2022-01-14 16:08:11 -05:00
committed by Bjørn Erik Pedersen
parent 22055176d2
commit 85d31f7bfb
3 changed files with 81 additions and 1 deletions

View File

@@ -635,7 +635,19 @@ func (p *pageState) RenderString(args ...interface{}) (template.HTML, error) {
}
}
c, err := p.pageOutput.cp.renderContentWithConverter(conv, []byte(s), false)
var cp *pageContentOutput
// If the current content provider is not yet initialized, do so now.
if lcp, ok := p.pageOutput.ContentProvider.(*page.LazyContentProvider); ok {
c := lcp.Init()
if pco, ok := c.(*pageContentOutput); ok {
cp = pco
}
} else {
cp = p.pageOutput.cp
}
c, err := cp.renderContentWithConverter(conv, []byte(s), false)
if err != nil {
return "", p.wrapError(err)
}