template

package
v0.9.19 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionContext

type ExecutionContext interface {
	GetTemplate() Template
	GetFactory() Factory
	GetData() interface{}
}

type ExecutionContextImpl

type ExecutionContextImpl struct {
	Template Template
	Factory  Factory
	Data     interface{}
}

func (*ExecutionContextImpl) GetData

func (instance *ExecutionContextImpl) GetData() interface{}

func (*ExecutionContextImpl) GetFactory

func (instance *ExecutionContextImpl) GetFactory() Factory

func (*ExecutionContextImpl) GetTemplate

func (instance *ExecutionContextImpl) GetTemplate() Template

type Factory

type Factory interface {
	New(name string, code string) (Template, error)
	NewFromReader(name string, reader io.Reader) (Template, error)
	NewFromFile(file string) (Template, error)

	Must(name string, code string) Template
	MustFromReader(name string, reader io.Reader) Template
	MustFromFile(file string) Template
}

type FactoryImpl

type FactoryImpl struct {
	FunctionProvider FunctionProvider
}

func (*FactoryImpl) Must

func (instance *FactoryImpl) Must(name string, code string) Template

func (*FactoryImpl) MustFromFile

func (instance *FactoryImpl) MustFromFile(file string) Template

func (*FactoryImpl) MustFromReader

func (instance *FactoryImpl) MustFromReader(name string, reader io.Reader) Template

func (*FactoryImpl) New

func (instance *FactoryImpl) New(name string, code string) (Template, error)

func (*FactoryImpl) NewFromFile

func (instance *FactoryImpl) NewFromFile(file string) (Template, error)

func (*FactoryImpl) NewFromReader

func (instance *FactoryImpl) NewFromReader(name string, reader io.Reader) (Template, error)

type Function

type Function interface {
	Execute(context ExecutionContext, args ...interface{}) (interface{}, error)
}

type FunctionProvider

type FunctionProvider interface {
	GetFunctions() (Functions, error)
}

type Functions

type Functions map[string]Function

func (Functions) CreateDummyFuncMap

func (instance Functions) CreateDummyFuncMap() (nt.FuncMap, error)

func (Functions) CreateFuncMap

func (instance Functions) CreateFuncMap(context ExecutionContext) (nt.FuncMap, error)

type Impl

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

func (*Impl) Execute

func (instance *Impl) Execute(data interface{}, target io.Writer) error

func (*Impl) ExecuteToString

func (instance *Impl) ExecuteToString(data interface{}) (string, error)

func (*Impl) GetSource

func (instance *Impl) GetSource() string

func (*Impl) GetSourceFile

func (instance *Impl) GetSourceFile() *string

func (*Impl) GetSourceName

func (instance *Impl) GetSourceName() string

func (*Impl) MustExecute

func (instance *Impl) MustExecute(data interface{}, target io.Writer)

func (*Impl) MustExecuteToString

func (instance *Impl) MustExecuteToString(data interface{}) string

func (*Impl) WithSourceFile

func (instance *Impl) WithSourceFile(sourceFile string) (Template, error)

type Template

type Template interface {
	WithSourceFile(sourceFile string) (Template, error)

	Execute(data interface{}, target io.Writer) error
	ExecuteToString(data interface{}) (string, error)
	MustExecute(data interface{}, target io.Writer)
	MustExecuteToString(data interface{}) string

	GetSource() string
	GetSourceName() string
	GetSourceFile() *string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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