tpl

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Root      string
	Extension string
	Master    string
	FS        verbisfs.FS
}

Config represents the options for passing.

func (Config) GetExtension

func (c Config) GetExtension() string

GetExtension

Returns the template extension.

func (Config) GetFS

func (c Config) GetFS() verbisfs.FS

GetFS

Returns the the file system if there is one.

func (Config) GetMaster

func (c Config) GetMaster() string

GetMaster

Returns the template master layout.

func (Config) GetRoot

func (c Config) GetRoot() string

GetRoot

Returns the view root.

type TemplateConfig

type TemplateConfig interface {
	GetRoot() string
	GetExtension() string
	GetMaster() string
	GetFS() verbisfs.FS
}

TemplateConfig represents the functions for obtaining the executor configuration including "root", "master" and "extension".

type TemplateDataGetter

type TemplateDataGetter interface {
	Data(ctx *gin.Context, post *domain.PostDatum) interface{}
}

TemplateDataGetter represents the the Data function for obtaining post relevant data to send back to the template.

type TemplateExecutor

type TemplateExecutor interface {
	Exists(template string) bool
	Execute(w io.Writer, name string, data interface{}) (string, error)
	ExecutePost(w io.Writer, name string, ctx *gin.Context, post *domain.PostDatum) (string, error)
	Config() TemplateConfig
	Executor() TemplateExecutor
}

TemplateExecutor represents the functions for executing template.

type TemplateFuncGetter

type TemplateFuncGetter interface {
	FuncMap(ctx *gin.Context, post *domain.PostDatum, cfg TemplateConfig) template.FuncMap
	GenericFuncMap() template.FuncMap
}

TemplateFuncGetter represents the functions for obtaining template.FuncMap's for use in Verbis templates.

type TemplateHandler

type TemplateHandler interface {
	TemplateFuncGetter
	TemplateDataGetter
	Prepare(c TemplateConfig) TemplateExecutor
	ExecuteTpl(w io.Writer, text string, data interface{}) error
}

TemplateHandler is the main template renderer for Verbis It's responsible for preparing and executing templates and obtaining information such as function maps and post specific data.

Jump to

Keyboard shortcuts

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