diff options
author | Bjørn Erik Pedersen <[email protected]> | 2018-10-24 13:32:46 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2018-10-24 13:54:04 +0200 |
commit | 2d7709d15584e4c11138cd7fe92717a2a58e4585 (patch) | |
tree | d033ec9bae00cd07629344930235c666f7478081 /tpl | |
parent | deff9e154bc0371af56741ddb22cb1f9e392838a (diff) | |
download | hugo-2d7709d15584e4c11138cd7fe92717a2a58e4585.tar.gz hugo-2d7709d15584e4c11138cd7fe92717a2a58e4585.zip |
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')
-rw-r--r-- | tpl/template.go | 4 |
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) |