gf/geg/os/gview/template/main.go

21 lines
433 B
Go
Raw Normal View History

2018-09-03 13:05:41 +08:00
package main
import (
"fmt"
"gitee.com/johng/gf/g"
"gitee.com/johng/gf/g/os/gfile"
)
func main() {
v := g.View()
// 设置模板目录为当前main.go所在目录下的template目录
v.AddPath(gfile.MainPkgPath() + gfile.Separator + "template2")
2018-09-03 13:05:41 +08:00
b, err := v.Parse("index.html", map[string]interface{} {
"k" : "v",
})
if err != nil {
panic(err)
}
2018-09-03 13:05:41 +08:00
fmt.Println(string(b))
}