macros

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

func (*MacroExecutor) Execute

func (e *MacroExecutor) Execute(macro *Macro, ctx runtime.Context, args []interface{}, kwargs map[string]interface{}) (interface{}, error)

Execute executes a macro with the given arguments

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

func (*MacroRegistry) Register

func (r *MacroRegistry) Register(name string, macro *Macro) error

Register registers a macro in the registry

Jump to

Keyboard shortcuts

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