mirror of
https://github.com/gin-gonic/gin.git
synced 2026-01-10 08:27:00 +08:00
Merge 029b60d02eceb73f1a1616d62d2f40c24c552f53 into 53799774f45a119234a89f791565e53aa26b4482
This commit is contained in:
commit
c8b25699a5
@ -570,14 +570,15 @@ Using templates with same name in different directories
|
|||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
router.LoadHTMLGlob("templates/**/*")
|
router.LoadHTMLGlob("templates/posts/*")
|
||||||
router.GET("/posts/index", func(c *gin.Context) {
|
router.GET("/posts/index", func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "posts/index.tmpl", gin.H{
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||||
"title": "Posts",
|
"title": "Posts",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
router.LoadHTMLGlob("templates/users/*")
|
||||||
router.GET("/users/index", func(c *gin.Context) {
|
router.GET("/users/index", func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "users/index.tmpl", gin.H{
|
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||||
"title": "Users",
|
"title": "Users",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user