-
Notifications
You must be signed in to change notification settings - Fork 5
/
doc.go
37 lines (32 loc) · 1.14 KB
/
doc.go
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
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2014 Alex Kalyvitis
/*
Package mustache is an implementation of the mustache templating language in Go.
For more information on mustache check out the official documentation at
http://mustache.github.io.
temlpate := mustache.New()
err := template.ParseString("Hello, {{subject}}!")
if err != nil {
// handle error
}
s, err := template.RenderString(map[string]string{"subject": "world"})
if err != nil {
// handle error
}
fmt.Println(s)
There are several wrappers of Parse and Render to help with different input or
output types. It is quite common to need to write the output of the template to
an http.ResponseWriter. In this case the Render function is the most apropriate.
import "net/http"
import "github.com/alexkappa/mustache"
func ServeHTTP(w http.ResponseWriter, r *http.Request) {
template, err := mustache.ParseString("Hello, {{subject}}!")
if err != nil {
// handle error
}
err = template.Render(w, map[string]string{"subject": "world"})
if err != nil {
// handle error
}
}
*/
package mustache