From 029b60d02eceb73f1a1616d62d2f40c24c552f53 Mon Sep 17 00:00:00 2001 From: Shuai Qi Date: Wed, 12 Apr 2017 21:14:54 +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 codding. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 883f9d50..732b37f4 100644 --- a/README.md +++ b/README.md @@ -570,14 +570,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", }) })