diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-24 13:32:46 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2018-10-24 13:54:04 +0200 |
commit | 2d7709d15584e4c11138cd7fe92717a2a58e4585 (patch) | |
tree | d033ec9bae00cd07629344930235c666f7478081 /hugolib | |
parent | deff9e154bc0371af56741ddb22cb1f9e392838a (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 'hugolib')
-rw-r--r-- | hugolib/hugo_sites_build_errors_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/hugolib/hugo_sites_build_errors_test.go b/hugolib/hugo_sites_build_errors_test.go index 8e913f061..8c5016225 100644 --- a/hugolib/hugo_sites_build_errors_test.go +++ b/hugolib/hugo_sites_build_errors_test.go @@ -108,6 +108,21 @@ func TestSiteBuildErrors(t *testing.T) { }, }, { + name: "Single template execute failed, long keyword", + fileType: single, + fileFixer: func(content string) string { + return strings.Replace(content, ".Title", ".ThisIsAVeryLongTitle", 1) + }, + assertBuildError: func(a testSiteBuildErrorAsserter, err error) { + fe := a.getFileError(err) + assert.Equal(5, fe.LineNumber) + assert.Equal(14, fe.ColumnNumber) + assert.Equal("go-html-template", fe.ChromaLexer) + a.assertErrorMessage("\"layouts/_default/single.html:5:14\": execute of template failed", fe.Error()) + + }, + }, + { name: "Shortcode parse failed", fileType: shortcode, fileFixer: func(content string) string { |