tpl: Add proper file context to template parse errors

Fixes #13604
This commit is contained in:
Bjørn Erik Pedersen
2025-04-14 11:20:36 +02:00
parent 1e0287f472
commit 8a2830f2dc
3 changed files with 60 additions and 16 deletions

View File

@@ -44,7 +44,16 @@ var embeddedTemplatesAliases = map[string][]string{
"_shortcodes/twitter.html": {"_shortcodes/tweet.html"},
}
func (t *templateNamespace) parseTemplate(ti *TemplInfo) error {
func (s *TemplateStore) parseTemplate(ti *TemplInfo) error {
err := s.tns.doParseTemplate(ti)
if err != nil {
return s.addFileContext(ti, "parse of template failed", err)
}
return err
}
func (t *templateNamespace) doParseTemplate(ti *TemplInfo) error {
if !ti.noBaseOf || ti.category == CategoryBaseof {
// Delay parsing until we have the base template.
return nil