Skip to content

Instantly share code, notes, and snippets.

@apriendeau
Created October 6, 2014 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apriendeau/fd91da6928228c4221b8 to your computer and use it in GitHub Desktop.
Save apriendeau/fd91da6928228c4221b8 to your computer and use it in GitHub Desktop.
Gin html render example
<html>
<head>
<title>{{.title}}</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.LoadHTMLTemplates("templates/*")
r.GET("/index", func(c *gin.Context) {
obj := gin.H{"title": "Main website"}
c.HTML(200, "index.tmpl", obj)
})
// Listen and server on 0.0.0.0:8080
r.Run(":8080")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment