<!-- lang: cpp --> package main
import ( "html/template" "log" "os" "io/IoUtil" ) func main() { s := ParseTmplateToStr("src/1.html") t,_ := template.New("test").Funcs(template.FuncMap{"Parse": ParseTmplateToStr }).Parse(s) t.Execute(os.Stdout,nil) } func ParseTmplateToStr(tname string) string { b,err := IoUtil.ReadFile(tname) if err != nil { log.Println(err) } s := string(b) return s } 1.html 1111111111 {{ Parse "src/2.html"}}