api

package
v0.0.0-...-71a30d0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env interface {
	New() (Env, error)
	Copy() (Env, error)
	Keys() []string
	Map() map[string]Value
	Get(name string) (Value, bool)
	Set(name string, value Value) error
	Update(env Env) error
	Eval(src string) (Value, error)
}

type Option

type Option func(opt Options) (any, error)

type Options

type Options interface {
	Set(opt Option) error
	Get(opt Option) (any, bool)
	String() string
}

type ParseTree

type ParseTree interface {
	Depth() int
	Length() int
	Parent() ParseTree
	Node() TemplateNode
	Children() iter.Seq2[int, ParseTree]
	PrettyPrint() (string, error)
}

type Template

type Template interface {
	Engine() TemplateEngine
	Env() Env
	SetEnv(env map[string]any) error
	Render(params ...map[string]any) (string, error)
	Write(w io.StringWriter, params ...map[string]any) error
	Parse(src string) error
	ParseTree() ParseTree
}

type TemplateEngine

type TemplateEngine interface {
	Options() Options
	GetOption(opt Option) (any, bool)
	SetOptions(opts ...Option) error
	Read(reader io.Reader) (Template, error)
	ReadFile(path string) (Template, error)
	NewTemplate(src string) (Template, error)
	NewEnv() (Env, error)
	NewValue(value any) (Value, error)
}

type TemplateNode

type TemplateNode interface {
	Children() []TemplateNode
	Render(opts Options, env Env, w io.StringWriter) error
	Format() (string, string)
	String() string
}

type Value

type Value interface {
	New(value any) (Value, error)
	Bool() bool
	String() string
	Iter() (iter.Seq2[Value, Value], error)
}

Jump to

Keyboard shortcuts

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