Browse Source

Logged template errors on client-side and server-side instead of printing it

Wirecog 7 years ago
parent
commit
49b1ba93dd
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      template.go

+ 3
- 2
template.go View File

10
 	"errors"
10
 	"errors"
11
 	"html/template"
11
 	"html/template"
12
 	"io"
12
 	"io"
13
+	"log"
13
 	"strings"
14
 	"strings"
14
 
15
 
15
 	"honnef.co/go/js/dom"
16
 	"honnef.co/go/js/dom"
109
 	var tpl bytes.Buffer
110
 	var tpl bytes.Buffer
110
 
111
 
111
 	if err := t.Execute(&tpl, params.Data); err != nil {
112
 	if err := t.Execute(&tpl, params.Data); err != nil {
112
-		println("Error encountered when attempting to render template on client: ", err)
113
+		log.Println("Error encountered when attempting to render template on client: ", err)
113
 	}
114
 	}
114
 
115
 
115
 	if params.ShouldPopulateRenderedContent == true {
116
 	if params.ShouldPopulateRenderedContent == true {
149
 	w := params.Writer
150
 	w := params.Writer
150
 	var tpl bytes.Buffer
151
 	var tpl bytes.Buffer
151
 	if err := t.Execute(&tpl, params.Data); err != nil {
152
 	if err := t.Execute(&tpl, params.Data); err != nil {
152
-		println("Error encountered when attempting to render template on server: ", err)
153
+		log.Println("Error encountered when attempting to render template on server: ", err)
153
 	}
154
 	}
154
 	w.Write(tpl.Bytes())
155
 	w.Write(tpl.Bytes())
155
 }
156
 }