Skip to content

Google Cloud Storage Loader for pongo2 template files

License

Notifications You must be signed in to change notification settings

dieselburner/pongo2gcloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pongo2gcloud

Go Reference MIT license

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.

Usage

Import

import "github.com/dieselburner/pongo2gcloud"

Variables

Set ProjectID to your Google Cloud Project ID. If not set, pongo2gcloud will autodetect it when running on Google Cloud Engine, otherwise will panic.

Example

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,
})

About

Google Cloud Storage Loader for pongo2 template files

Resources

License

Stars

Watchers

Forks

Languages