mirror of
https://gitee.com/johng/gf
synced 2026-06-25 01:05:41 +08:00
22 lines
391 B
Go
22 lines
391 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gogf/gf/frame/g"
|
|
"github.com/gogf/gf/os/gfile"
|
|
)
|
|
|
|
func main() {
|
|
v := g.View()
|
|
// 设置模板目录为当前main.go所在目录下的template目录
|
|
v.AddPath(gfile.MainPkgPath() + gfile.Separator + "template2")
|
|
b, err := v.Parse("index.html", map[string]interface{}{
|
|
"k": "v",
|
|
})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(string(b))
|
|
}
|