mirror of
https://gitee.com/johng/gf
synced 2026-07-04 21:03:13 +08:00
模板引擎示例程序更新
This commit is contained in:
19
geg/os/gview/template/main.go
Normal file
19
geg/os/gview/template/main.go
Normal 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))
|
||||
}
|
||||
2
geg/os/gview/template/template/index.html
Normal file
2
geg/os/gview/template/template/index.html
Normal file
@ -0,0 +1,2 @@
|
||||
{{include "subs/sub.html" .}}
|
||||
|
||||
1
geg/os/gview/template/template/subs/sub.html
Normal file
1
geg/os/gview/template/template/subs/sub.html
Normal file
@ -0,0 +1 @@
|
||||
{{.}}
|
||||
Reference in New Issue
Block a user