Documentation ¶
Index ¶
- Constants
- func DefaultSymbols() map[string]map[string]reflect.Value
- func DefaultTags() []string
- type EmittedTemplate
- type ErrPostFailed
- type Set
- func (ts *Set) Add(ctx context.Context, name string, src fs.FS, unrestricted bool) (string, error)
- func (ts *Set) AddTemplates(ctx context.Context, src fs.FS, unrestricted bool) error
- func (ts *Set) Dump(out string)
- func (set *Set) Errors() []error
- func (ts *Set) Flags(name string) []xo.FlagSet
- func (ts *Set) For(mode string) error
- func (ts *Set) Has(name string) bool
- func (ts *Set) LoadDefault(ctx context.Context, name string) error
- func (ts *Set) LoadDefaults(ctx context.Context) error
- func (ts *Set) NewContext(ctx context.Context, mode string) context.Context
- func (ts *Set) NewTemplate(ctx context.Context, target string, src fs.FS, unrestricted bool) (*Target, error)
- func (ts *Set) Post(ctx context.Context, mode string)
- func (ts *Set) Pre(ctx context.Context, outDir string, mode string, set *xo.Set)
- func (ts *Set) Process(ctx context.Context, outDir string, mode string, set *xo.Set)
- func (ts *Set) Src() (fs.FS, error)
- func (ts *Set) Target() string
- func (ts *Set) Targets() []string
- func (ts *Set) Use(name string)
- type Target
Constants ¶
const DefaultInitFunc = "Init"
DefaultInitFunc is the template init symbol.
Variables ¶
This section is empty.
Functions ¶
func DefaultSymbols ¶
DefaultSymbols returns the default set of yaegi and internal symbols.
Types ¶
type EmittedTemplate ¶
EmittedTemplate wraps a template with its content and file name.
type ErrPostFailed ¶
ErrPostFailed is the post failed error.
func (*ErrPostFailed) Error ¶
func (err *ErrPostFailed) Error() string
Error satisfies the error interface.
func (*ErrPostFailed) Unwrap ¶
func (err *ErrPostFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set holds a set of templates and handles generating files for a target files.
Set should not be used more than once to output its contents.
func NewDefaultTemplateSet ¶
NewDefaultTemplateSet creates a template set using the default symbols, init func, tags, and embedded templates.
func NewTemplateSet ¶
func NewTemplateSet(symbols map[string]map[string]reflect.Value, initfunc string, tags ...string) *Set
NewTemplateSet creates a template set.
func (*Set) AddTemplates ¶
AddTemplates adds templates to the template set from src, adding a template for each subdirectory.
func (*Set) LoadDefault ¶
LoadDefault loads a single default target.
func (*Set) LoadDefaults ¶
LoadDefaults loads the default templates. Sets the default template target to "go" if available in embedded templates, or to the first available target.
func (*Set) NewContext ¶
NewContext creates a new context for the template target.
func (*Set) NewTemplate ¶
func (ts *Set) NewTemplate(ctx context.Context, target string, src fs.FS, unrestricted bool) (*Target, error)
NewTemplate creates a new template from the provided fs. Creates a github.com/traefik/yaegi interpreter and evaluates the template. See existing templates for implementation examples.
Uses the template set's symbols, init func name, and declared tags.