From 40af9ad6fc9f61a20490f540587afc783de433b2 Mon Sep 17 00:00:00 2001 From: Shuai Qi Date: Wed, 12 Apr 2017 10:43:22 +0800 Subject: [PATCH] ERROR:html/template: ".../index.html" is undefined There will be a error with loading template files as your guidance! Maybe my error code. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 82ea6a58..2a34db08 100644 --- a/README.md +++ b/README.md @@ -495,14 +495,15 @@ Using templates with same name in different directories ```go func main() { router := gin.Default() - router.LoadHTMLGlob("templates/**/*") + router.LoadHTMLGlob("templates/posts/*") 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", }) }) + router.LoadHTMLGlob("templates/users/*") 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", }) })