mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 22:34:27 +00:00
Print template parsing errors to aid troubleshooting
Added a new Template.PrintErrors() function call, used in hugolib/site.go#Process() so it does not clutter up `go test -v ./...` results. Special thanks to @tatsushid for mapping out the call trace which makes it a lot easier to find the appropriate places to place the Template.PrintErrors() call. Fixes #316
This commit is contained in:
parent
d1364ffb68
commit
c50780930e
2 changed files with 8 additions and 0 deletions
|
@ -269,6 +269,7 @@ func (s *Site) Process() (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.prepTemplates()
|
s.prepTemplates()
|
||||||
|
s.Tmpl.PrintErrors()
|
||||||
s.timerStep("initialize & template prep")
|
s.timerStep("initialize & template prep")
|
||||||
if err = s.CreatePages(); err != nil {
|
if err = s.CreatePages(); err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -50,6 +50,7 @@ type Template interface {
|
||||||
AddTemplate(name, tpl string) error
|
AddTemplate(name, tpl string) error
|
||||||
AddInternalTemplate(prefix, name, tpl string) error
|
AddInternalTemplate(prefix, name, tpl string) error
|
||||||
AddInternalShortcode(name, tpl string) error
|
AddInternalShortcode(name, tpl string) error
|
||||||
|
PrintErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
type templateErr struct {
|
type templateErr struct {
|
||||||
|
@ -1253,6 +1254,12 @@ func (t *GoHtmlTemplate) LoadTemplates(absPath string) {
|
||||||
t.loadTemplates(absPath, "")
|
t.loadTemplates(absPath, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *GoHtmlTemplate) PrintErrors() {
|
||||||
|
for _, e := range t.errors {
|
||||||
|
jww.ERROR.Println(e.err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
funcMap = template.FuncMap{
|
funcMap = template.FuncMap{
|
||||||
"urlize": helpers.Urlize,
|
"urlize": helpers.Urlize,
|
||||||
|
|
Loading…
Add table
Reference in a new issue