diff --git a/.example/os/gview/layout/layout1/main.go b/.example/os/gview/layout/layout1/main.go
index 660cca012..ed12906bc 100644
--- a/.example/os/gview/layout/layout1/main.go
+++ b/.example/os/gview/layout/layout1/main.go
@@ -2,19 +2,18 @@ package main
import (
"github.com/gogf/gf/frame/g"
- "github.com/gogf/gf/frame/gmvc"
+ "github.com/gogf/gf/net/ghttp"
)
-type Controller struct {
- gmvc.Controller
-}
-
-func (c *Controller) Test() {
- c.View.Display("layout.html")
-}
func main() {
s := g.Server()
- s.BindControllerMethod("/", new(Controller), "Test")
+ s.BindHandler("/", func(r *ghttp.Request) {
+ r.Response.WriteTpl("layout.html", g.Map{
+ "header": "This is header",
+ "container": "This is container",
+ "footer": "This is footer",
+ })
+ })
s.SetPort(8199)
s.Run()
}
diff --git a/.example/os/gview/layout/layout1/template/container.html b/.example/os/gview/layout/layout1/template/container.html
index 5902716a8..4f6af6313 100644
--- a/.example/os/gview/layout/layout1/template/container.html
+++ b/.example/os/gview/layout/layout1/template/container.html
@@ -1,3 +1,3 @@
{{define "container"}}
-
CONTAINER
+{{.container}}
{{end}}
\ No newline at end of file
diff --git a/.example/os/gview/layout/layout1/template/footer.html b/.example/os/gview/layout/layout1/template/footer.html
index 782a3c05f..8a5f09a53 100644
--- a/.example/os/gview/layout/layout1/template/footer.html
+++ b/.example/os/gview/layout/layout1/template/footer.html
@@ -1,3 +1,3 @@
{{define "footer"}}
-FOOTER
+{{.footer}}
{{end}}
\ No newline at end of file
diff --git a/.example/os/gview/layout/layout1/template/header.html b/.example/os/gview/layout/layout1/template/header.html
index 7e2c837c4..bc500316a 100644
--- a/.example/os/gview/layout/layout1/template/header.html
+++ b/.example/os/gview/layout/layout1/template/header.html
@@ -1,3 +1,3 @@
{{define "header"}}
- HEADER
+ {{.header}}
{{end}}
\ No newline at end of file
diff --git a/.example/os/gview/layout/layout1/template/layout.html b/.example/os/gview/layout/layout1/template/layout.html
index 8c117123a..223fce6b8 100644
--- a/.example/os/gview/layout/layout1/template/layout.html
+++ b/.example/os/gview/layout/layout1/template/layout.html
@@ -2,14 +2,14 @@
GoFrame Layout
- {{template "header"}}
+ {{template "header" .}}
- {{template "container"}}
+ {{template "container" .}}
\ No newline at end of file
diff --git a/.example/os/gview/layout/layout2/main.go b/.example/os/gview/layout/layout2/main.go
index f0abb36ec..f90ae6fc1 100644
--- a/.example/os/gview/layout/layout2/main.go
+++ b/.example/os/gview/layout/layout2/main.go
@@ -9,11 +9,13 @@ func main() {
s := g.Server()
s.BindHandler("/main1", func(r *ghttp.Request) {
r.Response.WriteTpl("layout.html", g.Map{
+ "name": "smith",
"mainTpl": "main/main1.html",
})
})
s.BindHandler("/main2", func(r *ghttp.Request) {
r.Response.WriteTpl("layout.html", g.Map{
+ "name": "john",
"mainTpl": "main/main2.html",
})
})