3 Star 3 Fork 2

shxsun/gosuv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
res_bindata.go 799 Bytes
一键复制 编辑 原始数据 按行查看 历史
codeskyblue 提交于 2016-08-31 11:12 . update readme
// +build bindata
package main
import (
"html/template"
"io"
"log"
"net/http"
"path/filepath"
)
var tmpl *template.Template
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))
}
func init() {
http.Handle("/res/", http.StripPrefix("/res/", http.FileServer(assetFS())))
}
func executeTemplate(wr io.Writer, name string, data interface{}) {
if tmpl == nil || tmpl.Lookup(name) == nil {
path := filepath.Join(templateDir, name+".html")
data, err := Asset(path)
if err != nil {
log.Fatal(err)
}
parseTemplate(name, string(data))
}
tmpl.ExecuteTemplate(wr, name, data)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/shxsun/gosuv.git
git@gitee.com:shxsun/gosuv.git
shxsun
gosuv
gosuv
master

搜索帮助

A270a887 8829481 3d7a4017 8829481