pongo2 provides Django-syntax like templating language for Go applications. One of the great things about pongo2 is that it supports template sets and custom template loaders.
This package adds support for loading templates from Google Cloud Storage.
import "github.com/dieselburner/pongo2gcloud"
Set ProjectID
to your Google Cloud Project ID. If not set, pongo2gcloud
will autodetect it when running on Google Cloud Engine, otherwise will panic.
Gin example:
import (
...
"github.com/dieselburner/pongo2gcloud"
"github.com/flosch/pongo2/v5"
"gitlab.com/go-box/pongo2gin"
...
)
template_set := pongo2.NewSet("gcloud", &pongo2gcloud.Loader{
ProjectID: os.Getenv("GOOGLE_CLOUD_PROJECT"),
})
router.HTMLRender = pongo2gin.New(pongo2gin.RenderOptions{
ContentType: "text/html; charset=utf-8",
TemplateDir: "templates",
TemplateSet: template_set,
})