tpl: Prepare for template metrics
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 19 Aug 2017 07:57:37 +0000 (09:57 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 19 Aug 2017 07:57:37 +0000 (09:57 +0200)
tpl/template.go

index 02d4a541c8064e82fbbd976cf98dfc4eea384b78..7be496df9b1e7cf97bcc620463fbd39063b529f9 100644 (file)
@@ -68,6 +68,14 @@ type TemplateAdapter struct {
        Template
 }
 
+// Execute executes the current template. The actual execution is performed
+// by the embedded text or html template, but we add an implementation here so
+// we can add a timer for some metrics.
+func (t *TemplateAdapter) Execute(w io.Writer, data interface{}) error {
+       // TODO(moorereason) metrics fmt.Println("Execute:", t.Name())
+       return t.Template.Execute(w, data)
+}
+
 // ExecuteToString executes the current template and returns the result as a
 // string.
 func (t *TemplateAdapter) ExecuteToString(data interface{}) (string, error) {