mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
添加模板测试代码
This commit is contained in:
@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitee.com/johng/gf/g"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.BindHandler("/", func(r *ghttp.Request){
|
||||
content :=`{{if (get "name")}} {{get "name"}} {{else}} NoName {{end}}`
|
||||
r.Response.WriteTplContent(content, nil)
|
||||
})
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
11
geg/net/ghttp/server/template/tpl1/index.html
Normal file
11
geg/net/ghttp/server/template/tpl1/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{.title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<H1>姓名 : {{.name}}</H1>
|
||||
12311
|
||||
</body>
|
||||
</html>
|
||||
23
geg/net/ghttp/server/template/tpl1/tpl1.go
Normal file
23
geg/net/ghttp/server/template/tpl1/tpl1.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitee.com/johng/gf/g/frame/gmvc"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
)
|
||||
type ControllerIndex struct {
|
||||
gmvc.Controller
|
||||
}
|
||||
func (c *ControllerIndex) Info() {
|
||||
c.View.Assign("title", "Go Frame 第一个网站")
|
||||
c.View.Assigns(map[string]interface{}{
|
||||
"name" : "很开心1",
|
||||
"score" : 100,
|
||||
})
|
||||
c.View.Display("index.html")
|
||||
}
|
||||
func main() {
|
||||
s := ghttp.GetServer()
|
||||
s.BindController("/", new(ControllerIndex))
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
<- make(chan struct{})
|
||||
fmt.Print(1)
|
||||
}
|
||||
Reference in New Issue
Block a user