I'm goofing around with GIN and trying some examples. I can't get templating to work for me.
File inclusion works, but variable substitution does not. GOLANG version 1.20.12 package main import "github.com/gin-gonic/gin" import "net/http" // import "gorm.io/driver/sqlite" // import "gorm.io/gorm" func main() { server := gin.Default() server.Static("/stylesheets", "./") server.LoadHTMLGlob("templates/*.html") server.GET("/test", func(ctx *gin.Context) { ctx.JSON(200, gin.H{ "message": "OK!!", }) }) server.GET("/temp", func(ctx *gin.Context) { ctx.HTML(http.StatusOK, "index.html", gin.H{ "title": "Main website", "foo": "bar", }) }) server.GET("/index", func(ctx *gin.Context) { ctx.JSON(200, gin.H{ "message": "OK!!", }) }) server.Run(":8080") } Specifically, opening a browser and accessing the /temp endpoint doesn't change the title or print the text of 'foo' templates/header.html: <!DOCTYPE html> <title>{{.title}}</title> <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> </head> <body class="container"> What's going on here? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6f292267-c78f-44b8-a020-d73fb5ce64e2n%40googlegroups.com.