ref: c50780930e1f30dec3c0a5356a5b18d0dc67e4b9
parent: d1364ffb684a2a7d26a71027f1464a052405fd01
author: Anthony Fok <[email protected]>
date: Fri Jan 30 11:56:25 EST 2015
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
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -269,6 +269,7 @@
return
}
s.prepTemplates()
+ s.Tmpl.PrintErrors()
s.timerStep("initialize & template prep")
if err = s.CreatePages(); err != nil {
return
--- a/tpl/template.go
+++ b/tpl/template.go
@@ -50,6 +50,7 @@
AddTemplate(name, tpl string) error
AddInternalTemplate(prefix, name, tpl string) error
AddInternalShortcode(name, tpl string) error
+ PrintErrors()
}
type templateErr struct {
@@ -1251,6 +1252,12 @@
func (t *GoHtmlTemplate) LoadTemplates(absPath string) {
t.loadTemplates(absPath, "")
+}
+
+func (t *GoHtmlTemplate) PrintErrors() {
+ for _, e := range t.errors {
+ jww.ERROR.Println(e.err)
+ }
}
func init() {