echojet

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

library github.com/CloudyKit/jet

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JetRender

type JetRender struct {
	Options *RenderOptions
	JetSet  *jet.Set
}

JetRender is a custom Gin template renderer using Pongo2.

func Default

func Default() (jr *JetRender)

Default creates a JetRender instance with default options.

func New

func New(options RenderOptions) *JetRender

New creates a new JetRender instance with custom Options.

func (*JetRender) Render

func (p *JetRender) Render(w io.Writer, name string, data interface{}, c echo.Context) error

Render should render the template to the response.

func (*JetRender) WriteContentType

func (p *JetRender) WriteContentType(w io.Writer)

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

type RenderOptions

type RenderOptions struct {
	TemplateDir string
	ContentType string
	VarMap      *VarMapMx
}

RenderOptions is used to configure the renderer.

type VarMapMx

type VarMapMx struct {
	// contains filtered or unexported fields
}

VarMapMx defines a mutex-protected jet.VarMap that's usable concurrently.

func NewVarMapMx

func NewVarMapMx() *VarMapMx

NewVarMapMx returns an initialized VarMapMx instance that is ready to be used.

func (*VarMapMx) Get

func (scope *VarMapMx) Get(name string) reflect.Value

Get returns the value for a key in the embedded jet.VarMap. The returned reflect.Value is not valid if the key does not exist.

func (*VarMapMx) GetVarMap

func (scope *VarMapMx) GetVarMap() jet.VarMap

GetVarMap returns the embedded jet.VarMap for use in template executions.

func (*VarMapMx) Lookup

func (scope *VarMapMx) Lookup(name string) (reflect.Value, bool)

Lookup returns the value for a key in the embedded jet.VarMap as well as whether the key was found or not.

func (*VarMapMx) Set

func (scope *VarMapMx) Set(name string, v interface{}) *VarMapMx

Set adds the key value pair in the embedded jet.VarMap.

func (*VarMapMx) SetFunc

func (scope *VarMapMx) SetFunc(name string, v jet.Func) *VarMapMx

SetFunc adds a jet.Func to the embedded jet.VarMap.

func (*VarMapMx) SetWriter

func (scope *VarMapMx) SetWriter(name string, v jet.SafeWriter) *VarMapMx

SetWriter adds a jet.SafeWriter to the embedded jet.VarMap.

Jump to

Keyboard shortcuts

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