Standard library / html/template

html/template.Template

A parsed template and its associated named definitions. Parse before executing; share immutable templates with separate writers. Expected stdout: 'Hello Ada\n'.

Formal Syntax & Structure

go syntaxgo
type Template struct {
  Tree *parse.Tree}

Working Example

Example Snippetgo
package main
import (  "fmt"  "html/template"  "os")
func check(e error) {  if e != nil {    panic(e)  }}
func main() {  t := template.Must(template.New("greet").Parse("Hello {{.}}"))  check(t.Execute(os.Stdout, "Ada"))  fmt.Println()}
Go Reference