mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
模板引擎示例程序更新
This commit is contained in:
5
TODO
5
TODO
@ -22,7 +22,10 @@ ghttp增加route name特性,并同时支持backend和template(提供内置函
|
||||
ghttp日志增加客户端IP信息;
|
||||
ghttp.Client自动Close机制;
|
||||
gvalid校验支持当第一个规则失败后便不再校验后续的规则,最好做成链式操作;
|
||||
gvalid返回的数据类型调整map[string]map[string]string->map[string]map[string]error,这样更容易被第三方框架兼容;
|
||||
检查ghttp.Server超时问题;
|
||||
|
||||
|
||||
|
||||
|
||||
DONE:
|
||||
1. gconv完善针对不同类型的判断,例如:尽量减少sprintf("%v", xxx)来执行string类型的转换;
|
||||
|
||||
@ -152,3 +152,4 @@ func (view *View) funcInclude(file string, data...map[string]interface{}) templa
|
||||
}
|
||||
return template.HTML(content)
|
||||
}
|
||||
|
||||
|
||||
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