Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrComponentNotFound = errors.New("component not found")
ErrComponentNotFound is returned by Importer implementations when a component is not found.
Functions ¶
func AnyPlusAny ¶
Types ¶
type Component ¶
type Component interface {
Render(s Scope) (*RenderResult, error)
}
type Importer ¶
Importer defines an interface for importing components, providing a method to retrieve a component provider by name. The component provider is a function that instantiates components, typically called during CHTML template parsing. For efficiency, the Import method can be invoked once at app initialization, assuming all components are known, and caching is handled to prevent redundant loads.
type ImporterFunc ¶
ImporterFunc allows ordinary functions to act as Importer instances.
type RenderResult ¶
type Scope ¶
type Scope interface { // Parent returns the parent scope of the current scope or nil if it's the root scope. Parent() Scope // Spawn creates a new child scope with extra variables added to it. Spawn(vars map[string]any) Scope // Vars returns all variables in the scope. Vars() map[string]any // Closed returns a channel that is closed when the scope is not going to be rendered. Closed() <-chan struct{} // Touch marks the scope as changed. The change is propagated to the parent scopes. Touch() }
Scope defines an interface for managing arguments in a CHTML component. The CHTML component creates a new scope for each loop iteration, conditional branch, and component import with Spawn method.
type ScopeMap ¶
type ScopeMap struct {
// contains filtered or unexported fields
}
ScopeMap is a simple implementation of the Scope interface based on map[string]any type and suitable to work with expr-lang's env. This implementation copies the variables from the parent scope to the child scope.
func NewScopeMap ¶
func (*ScopeMap) Parent ¶
Parent returns the parent scope of the current scope or nil if it's the root scope.