Golang html/template.Template type examples
package html/template
Template is a specialized Template from "text/template" that produces a safe HTML document fragment.
Golang html/template.Template type usage examples
Example 1:
var Templates = make(map[string]*template.Template)
func registerTemplate(name string, t *template.Template) {
Templates[name] = t
}
Example 2:
var templates *template.Template
templates = template.Must(template.ParseFiles(cfg.template))
Example 3:
var defaultTemplate string = '<!DOCTYPE html><html lang="en"><head><title>{{ .ClusterName }}</title></head><body ..........' // fill up here
var tmpl *template.Template
var err error
tmpl, err = template.New("base").Parse(defaultTemplate)
References :
https://github.com/AcalephStorage/consul-alerts/blob/master/notifier/email-notifier.go
Advertisement
Something interesting
Tutorials
+46.2k Golang : Read tab delimited file with encoding/csv package
+20k Golang : How to run your code only once with sync.Once object
+9.6k Golang : How to generate Code 39 barcode?
+28k Golang : Move file to another directory
+31.9k Golang : Convert an image file to []byte
+8.8k Golang : Heap sort example
+22.1k Golang : Join arrays or slices example
+13.5k Golang : Read XML elements data with xml.CharData example
+7.9k Golang : Trim everything onward after a word
+22.7k Golang : Strings to lowercase and uppercase example
+14.6k Golang : Reset buffer example