https://github.com/flosch/ginpongo2
https://github.com/flosch/ginpongo2
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/flosch/ginpongo2
- Owner: flosch
- License: mit
- Fork: true (ngerakines/ginpongo2)
- Created: 2014-07-22T01:03:00.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-07-22T08:22:14.000Z (almost 12 years ago)
- Last Synced: 2024-06-21T02:17:35.740Z (about 2 years ago)
- Size: 104 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
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 main
import (
"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")
}
```