Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-24 14:32:46 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-24 14:54:04 +0300
commit2d7709d15584e4c11138cd7fe92717a2a58e4585 (patch)
treed033ec9bae00cd07629344930235c666f7478081 /tpl/template.go
parentdeff9e154bc0371af56741ddb22cb1f9e392838a (diff)
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
Diffstat (limited to 'tpl/template.go')
-rw-r--r--tpl/template.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/tpl/template.go b/tpl/template.go
index 968705493..913b20ed2 100644
--- a/tpl/template.go
+++ b/tpl/template.go
@@ -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)