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,6 +10,7 @@ import (
10 10
 	"errors"
11 11
 	"html/template"
12 12
 	"io"
13
+	"log"
13 14
 	"strings"
14 15
 
15 16
 	"honnef.co/go/js/dom"
@@ -109,7 +110,7 @@ func (t *Template) RenderTemplateOnClient(params *RenderParams) {
109 110
 	var tpl bytes.Buffer
110 111
 
111 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 116
 	if params.ShouldPopulateRenderedContent == true {
@@ -149,7 +150,7 @@ func (t *Template) RenderTemplateOnServer(params *RenderParams) {
149 150
 	w := params.Writer
150 151
 	var tpl bytes.Buffer
151 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 155
 	w.Write(tpl.Bytes())
155 156
 }