Documentation
¶
Index ¶
- type Macro
- type MacroContext
- type MacroExecutor
- type MacroFunc
- type MacroRegistry
- func (r *MacroRegistry) CallMacro(name string, ctx runtime.Context, evaluator runtime.Evaluator, ...) (interface{}, error)
- func (r *MacroRegistry) Clear()
- func (r *MacroRegistry) Get(name string) (*Macro, bool)
- func (r *MacroRegistry) Import(fromTemplate string, other *MacroRegistry, names []string) error
- func (r *MacroRegistry) List() []string
- func (r *MacroRegistry) Register(name string, macro *Macro) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Macro ¶
type Macro struct {
Name string
Parameters []string
Defaults map[string]interface{}
Body []parser.Node
Template string // Template name where macro is defined
}
Macro represents a template macro
type MacroContext ¶
type MacroContext struct {
// contains filtered or unexported fields
}
MacroContext provides macro-related context operations
func NewMacroContext ¶
func NewMacroContext() *MacroContext
NewMacroContext creates a new macro context
func (*MacroContext) Call ¶
func (mc *MacroContext) Call(name string, ctx runtime.Context, evaluator runtime.Evaluator, args []interface{}, kwargs map[string]interface{}) (interface{}, error)
Macro call helper for templates
func (*MacroContext) DefineMacro ¶
func (mc *MacroContext) DefineMacro(node *parser.MacroNode, templateName string) error
DefineMacro defines a macro from an AST node
func (*MacroContext) GetRegistry ¶
func (mc *MacroContext) GetRegistry() *MacroRegistry
GetRegistry returns the macro registry
type MacroExecutor ¶
type MacroExecutor struct {
// contains filtered or unexported fields
}
MacroExecutor handles macro execution
func NewMacroExecutor ¶
func NewMacroExecutor(evaluator runtime.Evaluator) *MacroExecutor
NewMacroExecutor creates a new macro executor
type MacroFunc ¶
type MacroFunc func(ctx runtime.Context, args []interface{}, kwargs map[string]interface{}) (interface{}, error)
MacroFunc represents a compiled macro function
type MacroRegistry ¶
type MacroRegistry struct {
// contains filtered or unexported fields
}
MacroRegistry manages template macros
func NewMacroRegistry ¶
func NewMacroRegistry() *MacroRegistry
NewMacroRegistry creates a new macro registry
func (*MacroRegistry) CallMacro ¶
func (r *MacroRegistry) CallMacro(name string, ctx runtime.Context, evaluator runtime.Evaluator, args []interface{}, kwargs map[string]interface{}) (interface{}, error)
CallMacro is a convenience function to call a macro
func (*MacroRegistry) Clear ¶
func (r *MacroRegistry) Clear()
Clear removes all macros from the registry
func (*MacroRegistry) Get ¶
func (r *MacroRegistry) Get(name string) (*Macro, bool)
Get retrieves a macro by name
func (*MacroRegistry) Import ¶
func (r *MacroRegistry) Import(fromTemplate string, other *MacroRegistry, names []string) error
Import imports macros from another template
func (*MacroRegistry) List ¶
func (r *MacroRegistry) List() []string
List returns all registered macro names