You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
436 B
25 lines
436 B
package main
|
|
|
|
import "html/template"
|
|
|
|
var (
|
|
tmpl *template.Template
|
|
templates = map[string]string{
|
|
"index": "res/index.html",
|
|
"setting": "res/setting.html",
|
|
}
|
|
)
|
|
|
|
func ParseTemplate(name string, content string) {
|
|
if tmpl == nil {
|
|
tmpl = template.New(name)
|
|
}
|
|
var t *template.Template
|
|
if tmpl.Name() == name {
|
|
t = tmpl
|
|
} else {
|
|
t = tmpl.New(name)
|
|
}
|
|
template.Must(t.New(name).Delims("[[", "]]").Parse(content))
|
|
}
|