mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
tpl: Handle truncated identifiers in Go template errors
Long identifiers will give errors on the format: ```bash _default/single.html:5:14: executing "main" at <.ThisIsAVeryLongTitl...>: can't evaluate field ThisIsAVeryLongTitle ``` Hugo use this value to match the "base template or not", so we need to strip the "...". Fixes #5346
This commit is contained in:
@@ -133,7 +133,9 @@ func (t *TemplateAdapter) Execute(w io.Writer, data interface{}) (execErr error)
|
||||
return
|
||||
}
|
||||
|
||||
var identifiersRe = regexp.MustCompile("at \\<(.*?)\\>:")
|
||||
// The identifiers may be truncated in the log, e.g.
|
||||
// "executing "main" at <$scaled.SRelPermalin...>: can't evaluate field SRelPermalink in type *resource.Image"
|
||||
var identifiersRe = regexp.MustCompile("at \\<(.*?)(\\.{3})?\\>:")
|
||||
|
||||
func (t *TemplateAdapter) extractIdentifiers(line string) []string {
|
||||
m := identifiersRe.FindAllStringSubmatch(line, -1)
|
||||
|
Reference in New Issue
Block a user