mirror of
https://github.com/gin-gonic/gin.git
synced 2026-01-10 08:27:00 +08:00
Merge 40af9ad6fc9f61a20490f540587afc783de433b2 into 53295a75a40173538e28ef9c9a8b696b2a5f8117
This commit is contained in:
commit
7a3c906d41
@ -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