templating

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmberEngine

type AmberEngine struct {
	Policy *bluemonday.Policy
	// contains filtered or unexported fields
}

AmberEngine Amber Rendering Engine

func NewAmber

func NewAmber(templatesFolder, ext string) (AmberEngine, error)

NewAmber creates a new AmberEngine

func (AmberEngine) Render

func (e AmberEngine) Render(file string, data interface{}, sanitize bool) ([]byte, error)

Render generates HTML from the template

func (AmberEngine) SanitizationPolicy

func (e AmberEngine) SanitizationPolicy() *bluemonday.Policy

SanitizationPolicy returns the html sanitization policy

func (AmberEngine) TemplatesFolder

func (e AmberEngine) TemplatesFolder() string

TemplatesFolder returns template folder

type DefaultEngine

type DefaultEngine struct {
	Policy *bluemonday.Policy
	// contains filtered or unexported fields
}

DefaultEngine Default Rendering Engine

func NewDefault

func NewDefault(templatesFolder string) DefaultEngine

NewDefault creates a new DefaultEngine

func (DefaultEngine) Render

func (e DefaultEngine) Render(file string, data interface{}, sanitize bool) ([]byte, error)

Render generates HTML from the template

func (DefaultEngine) SanitizationPolicy

func (e DefaultEngine) SanitizationPolicy() *bluemonday.Policy

SanitizationPolicy returns the html sanitization policy

func (DefaultEngine) TemplatesFolder

func (e DefaultEngine) TemplatesFolder() string

TemplatesFolder returns template folder

type Engine

type Engine interface {
	TemplatesFolder() string
	Render(template string, data interface{}, sanitize bool) ([]byte, error)
	SanitizationPolicy() *bluemonday.Policy
}

Engine is an interface to represent templating engines, or wrappers for templating engines

func GetEngine

func GetEngine(engineType EngineType, templatesFolder string) Engine

GetEngine gets an engine based on type, and returns a Engine

type EngineType

type EngineType uint8

EngineType Represents a template engine type

const (
	E_DEFAULT EngineType = 0 // html/template
	E_PONGO2  EngineType = 1 // https://github.com/flosch/pongo2
	E_AMBER   EngineType = 2 // https://github.com/eknkc/amber

)

type Pongo2Engine

type Pongo2Engine struct {
	Policy *bluemonday.Policy
	// contains filtered or unexported fields
}

Pongo2Engine Amber Rendering Engine

func NewPongo2

func NewPongo2(templatesFolder string) Pongo2Engine

NewPongo2 creates a new Pongo2Engine

func (Pongo2Engine) Render

func (e Pongo2Engine) Render(file string, data interface{}, sanitize bool) ([]byte, error)

Render generates HTML from the template

func (Pongo2Engine) SanitizationPolicy

func (e Pongo2Engine) SanitizationPolicy() *bluemonday.Policy

SanitizationPolicy returns the html sanitization policy

func (Pongo2Engine) TemplatesFolder

func (e Pongo2Engine) TemplatesFolder() string

TemplatesFolder returns template folder

Jump to

Keyboard shortcuts

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