关于 Gin 框架加载 html 页面的一点小疑问

Jaxon · · 5355 次点击
官方文档是有看的,我这边用的是两个 `index.html`,官方文档用的 `index.tmpl`,后缀不一样。 知道怎么用的,非常感谢:)
#2
更多评论
czyt
云在青天水在瓶
Using templates with same name in different directories ```go func main() { router := gin.Default() router.LoadHTMLGlob("templates/**/*") router.GET("/posts/index", func(c *gin.Context) { c.HTML(http.StatusOK, "posts/index.tmpl", gin.H{ "title": "Posts", }) }) router.GET("/users/index", func(c *gin.Context) { c.HTML(http.StatusOK, "users/index.tmpl", gin.H{ "title": "Users", }) }) router.Run(":8080") } ```
#1
https://gitee.com/jalright/ginmultitemplate
#3