Package pongo2echo is a template renderer that can be used with the minimalist Go web framework https://github.com/labstack/echo it uses the Pongo2 template library https://github.com/flosch/pongo2
pongo2 is a Django-syntax like templating-language (official website).
go get "github.com/stnc/pongo2echo"
Pongo4echo - pongo2 echo framework stability renderer / Compatible with pongo version 4
Requires Echo 4+ or higher and Pongo2.
Real Example [echo+pongo+gorm+pagination]
https://github.com/stnc/golang-echo-realworld-example-web-app
package main
import (
"net/http""github.com/flosch/pongo2""github.com/labstack/echo/v4""github.com/stnc/pongo2echo"
)
var (
data= pongo2.Context{}
mainRenderer= pongo2echo.Renderer{Debug: true} // use any renderer
)
//GetAllData all listfuncGetAllData(c echo.Context) error {
posts:= []string{
"Larry Ellison",
"Carlos Slim Helu",
"Mark Zuckerberg",
"Amancio Ortega ",
"Jeff Bezos",
" Warren Buffet ",
"Bill Gates",
"selman tunç",
}
returnc.Render(http.StatusOK, "templates/index.html",
pongo2.Context{"title": "hello echo fw", "posts": posts})
}
funcmain() {
e:=echo.New()
e.Renderer=mainRenderer//pongo2 inite.Debug=true// http://localhost:8888/homee.GET("/home", GetAllData)
// Start servere.Logger.Fatal(e.Start(":8888"))
}<h1> {{ title }}</h1>
{% for post in posts%}
<ul><li>{{post}}</li></ul>
{% endfor %}