Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngerakines/ginpongo2
https://github.com/ngerakines/ginpongo2
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ngerakines/ginpongo2
- Owner: ngerakines
- License: mit
- Created: 2014-07-03T19:25:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-08-19T13:09:44.000Z (over 4 years ago)
- Last Synced: 2024-06-19T03:03:50.626Z (7 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 32
- 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")
}```