https://github.com/ngerakines/ginpongo2
https://github.com/ngerakines/ginpongo2
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ngerakines/ginpongo2
- Owner: ngerakines
- License: mit
- Created: 2014-07-03T19:25:21.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-08-19T13:09:44.000Z (almost 5 years ago)
- Last Synced: 2025-03-31T11:02:48.632Z (3 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 33
- Watchers: 3
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ginpongo2
The `github.com/ngerakines/ginpongo2` package provides a middleware that can be used to render pongo2 templates.
## Example
To use this, first ensure that the middleware is being referenced by gin using `Use`. Then inide of your handler, use the context `Set` methods to set the "template" and "data" variables.
```go
package mainimport (
"github.com/gin-gonic/gin"
"github.com/ngerakines/ginpongo2"
"log"
)func main() {
r := gin.Default()
r.Use(ginpongo2.Pongo2())r.GET("/", func(c *gin.Context) {
c.Set("template", "index.html")
c.Set("data", map[string]interface{}{"message": "Hello World!"})
})e := r.Run(":8080")
}```