plushgin

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(p *Plush2Render, c gin.H) plush.Context

NewContext create a plush.Context

Types

type Plush2Render

type Plush2Render struct {
	Options *RenderOptions
	Name    string
	Context plush.Context
	// contains filtered or unexported fields
}

Plush2Render is a custom Gin template renderer using plush.

func Default

func Default() *Plush2Render

Default creates a Plush2Render instance with default options.

func New

func New(options RenderOptions) *Plush2Render

New creates a new Plush2Render instance with custom Options.

func (*Plush2Render) AddHelper

func (p *Plush2Render) AddHelper(fn string, f interface{})

func (*Plush2Render) Instance

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

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

func (*Plush2Render) Render

func (p *Plush2Render) Render(w http.ResponseWriter) error

Render should render the template to the response.

func (*Plush2Render) WriteContentType

func (p *Plush2Render) 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
	MaxCacheEntries int
}

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