Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

html templates

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
 
import (
    "os"
    "text/template"
)
 
type User struct {
    Name    string
    Bio     string
}
 
func main() {
    u := User{"John", "a regular user"}
 
    ut, err := template.New("users").Parse("The user is {{ .Name }} and he is {{ .Bio }}.")
     
    if err != nil {
        panic(err)
    }
 
    err = ut.Execute(os.Stdout, u)
 
    if err != nil {
        panic(err)
    }
}
Source by golangdocs.com #
 
PREVIOUS NEXT
Tagged: #html #templates
ADD COMMENT
Topic
Name
5+4 =