模板引擎示例程序更新

This commit is contained in:
john
2018-09-03 13:05:41 +08:00
parent fc91755b7e
commit 1adff2a3f2
5 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,19 @@
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 + "template")
b, err := v.Parse("index.html", map[string]interface{} {
"k" : "v",
})
fmt.Println(err)
fmt.Println(string(b))
}

View File

@ -0,0 +1,2 @@
{{include "subs/sub.html" .}}

View File

@ -0,0 +1 @@
{{.}}