pongo2echo

Package pongo2echo provides renderer for labstack's echo framework

MIT License

Stars
4

Pongo2Echo

pongo2echo provides pongo2 renderer for echo which is web application framework written by golang. Pongo2 is a template engine likes django-syntax for golang.

This package is useful when you use pongo2 template in echo.

Usage

Setup pongo2echo render when initialize echo.


import (
	"github.com/h3poteto/pongo2echo"
	"github.com/labstack/echo"
)

func main() {
	render := pongo2echo.NewRenderer()
	render.AddDirectory("server/templates")
	e := echo.New()
	e.Renderer = render

	e.GET("/", func(c echo.Context) error {
		// index.html.tpl is located in server/templates/index.html.tpl
		return c.Render(http.StatusOK, "index.html.tpl",  map[string]interface{}{"title": "Index"})
	})
	e.Logger.Fatal(e.Start(":1323"))
}

You can use pongo2 templte in Render function, and pass variables to template.

License

The package is available as open source under the terms of the MIT License.