mirror of
https://github.com/hamburghammer/gohttpserver.git
synced 2024-12-22 22:47:41 +01:00
25 lines
458 B
Go
25 lines
458 B
Go
|
package main
|
||
|
|
||
|
import "html/template"
|
||
|
|
||
|
var (
|
||
|
tmpl *template.Template
|
||
|
templates = map[string]string{
|
||
|
"index": "res/index.tmpl.html",
|
||
|
"ipa-install": "res/ipa-install.tmpl.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))
|
||
|
}
|