pongo2gin

package
v0.0.0-...-e0770a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pongo2gin is a template renderer that can be used with the Gin web framework https://github.com/gin-gonic/gin it uses the Pongo2 template library https://github.com/flosch/pongo2

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pongo2Render

type Pongo2Render struct {
	Options  *RenderOptions
	Template *pongo2.Template
	Context  pongo2.Context
}

Pongo2Render is a custom Gin template renderer using Pongo2.

func Default

func Default() *Pongo2Render

Default creates a Pongo2Render instance with default options.

func New

func New(options RenderOptions) *Pongo2Render

New creates a new Pongo2Render instance with custom Options.

func (Pongo2Render) Instance

func (p Pongo2Render) Instance(name string, data interface{}) render.Render

Instance should return a new Pongo2Render struct per request and prepare the template by either loading it from disk or using pongo2's cache.

func (Pongo2Render) Render

func (p Pongo2Render) Render(w http.ResponseWriter) error

Render should render the template to the response.

func (Pongo2Render) WriteContentType

func (p Pongo2Render) WriteContentType(w http.ResponseWriter)

WriteContentType should add the Content-Type header to the response when not set yet.

type RenderOptions

type RenderOptions struct {
	TemplateDir string
	ContentType string
}

RenderOptions is used to configure the renderer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL