diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2025-04-14 11:20:36 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2025-04-14 14:38:22 +0200 |
commit | 8a2830f2dcbf2c9b799ff8d1db9601da58f98494 (patch) | |
tree | 05c0c66d1f8da8c17f1bc06df5c9a5176a7a391a /tpl/tplimpl/templates.go | |
parent | 1e0287f4729f477c6b956fc50f0bfde0edecaa33 (diff) | |
download | hugo-8a2830f2dcbf2c9b799ff8d1db9601da58f98494.tar.gz hugo-8a2830f2dcbf2c9b799ff8d1db9601da58f98494.zip |
tpl: Add proper file context to template parse errors
Fixes #13604
Diffstat (limited to 'tpl/tplimpl/templates.go')
-rw-r--r-- | tpl/tplimpl/templates.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tpl/tplimpl/templates.go b/tpl/tplimpl/templates.go index f3f98f622..19de48e38 100644 --- a/tpl/tplimpl/templates.go +++ b/tpl/tplimpl/templates.go @@ -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 |