twikutil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 12 Imported by: 0

README

goulash/twikutil

GoDoc

Package twikutil provides several functions to make working with the (Twik)[https://github.com/go-twik/twik] language easier.

It also contains a subpackage key, which helps set variables prior to the execution of a twik script, as well as read them afterwards.

The implementation is not yet well documented, and also not quite finished. :-) For more information, see the documentation! :-)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFuncExists = errors.New("cannot set variable with name of existing function")

Functions

func Export

func Export(s *twik.Scope, fm FuncMap)

func Format

func Format(name string, v interface{}) string

func Func

func Func(name string, f interface{}) func([]interface{}) (interface{}, error)

Types

type Executer

type Executer struct {
	PreProcessor *pre.Processor
	// contains filtered or unexported fields
}

func New

func New(loader LoaderFunc) *Executer

func (*Executer) Create

func (e *Executer) Create(key string, fn interface{}) error

func (*Executer) Exec

func (e *Executer) Exec(file string) (s *twik.Scope, err error)

func (*Executer) ExecString

func (e *Executer) ExecString(name, code string) (s *twik.Scope, err error)

func (*Executer) Get

func (e *Executer) Get(key string) (interface{}, error)

It is an error to get a key that has already been used as a function.

func (*Executer) Has

func (e *Executer) Has(key string) bool

func (*Executer) Override

func (e *Executer) Override(key string, fn interface{}) error

func (*Executer) Scope

func (e *Executer) Scope() *twik.Scope

func (*Executer) Set

func (e *Executer) Set(key string, value interface{}) error

It is an error to use a key that has already been used as a function.

type FuncMap

type FuncMap map[string]interface{}

func (FuncMap) Export

func (fm FuncMap) Export(s *twik.Scope)

func (FuncMap) FormatList

func (fm FuncMap) FormatList() []string

func (FuncMap) Import

func (fm FuncMap) Import(o FuncMap)

func (FuncMap) Keys

func (fm FuncMap) Keys() []string

type LoaderFunc

type LoaderFunc func(*twik.Scope) FuncMap

type TypeError

type TypeError struct {
	Name string
	Fn   interface{}
	Got  interface{}
	Want []string
}

func NewTypeError

func NewTypeError(got interface{}, want []string) *TypeError

func (TypeError) Error

func (e TypeError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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