Documentation
¶
Index ¶
- Variables
- func LoadComponentTemplate(templateFs []byte) (string, error)
- func RegisterComponent(name string, constructor func() Component)
- func RegisterPlugin(p Plugin)
- func SetDevMode(enabled bool)
- func SetLogger(l Logger)
- func TriggerMount(c Component)
- func TriggerRouter(path string)
- func TriggerStore(module, store, key string, value interface{})
- func TriggerTemplate(componentID, html string)
- func TriggerUnmount(c Component)
- type App
- type Component
- type ConditionContent
- type ConditionDependency
- type ConditionalBranch
- type ConditionalBranchContent
- type ConditionalNode
- type HTMLComponent
- func (c *HTMLComponent) AddDependency(placeholderName string, dep Component)
- func (c *HTMLComponent) GetID() string
- func (c *HTMLComponent) GetName() string
- func (c *HTMLComponent) Init(store *state.Store)
- func (c *HTMLComponent) Mount()
- func (c *HTMLComponent) OnMount()
- func (c *HTMLComponent) OnUnmount()
- func (c *HTMLComponent) Render() (renderedTemplate string)
- func (c *HTMLComponent) SetComponent(component Component)
- func (c *HTMLComponent) SetRouteParams(params map[string]string)
- func (c *HTMLComponent) SetSlots(slots map[string]string)
- func (c *HTMLComponent) Unmount()
- type Logger
- type Node
- type Plugin
- type TextNode
Constants ¶
This section is empty.
Variables ¶
var ComponentRegistry = map[string]func() Component{}
ComponentRegistry holds constructors for components that can be loaded on-demand. Components can register themselves with a unique name and a constructor function returning a new instance of the component. This allows templates to reference components by name using runtime selection attributes like `rt-is`.
var DevMode bool
DevMode enables additional runtime checks and warnings for development. It is disabled by default.
Functions ¶
func LoadComponentTemplate ¶
func RegisterComponent ¶
RegisterComponent registers a component constructor under the provided name. When a template references the name via `rt-is`, the constructor will be invoked to create a new component instance at render time.
func RegisterPlugin ¶
func RegisterPlugin(p Plugin)
RegisterPlugin registers a plugin and allows it to add hooks.
func SetLogger ¶
func SetLogger(l Logger)
SetLogger allows applications to replace the default logger.
func TriggerRouter ¶
func TriggerRouter(path string)
TriggerRouter invokes router hooks with the given path.
func TriggerStore ¶
func TriggerStore(module, store, key string, value interface{})
TriggerStore invokes store hooks for a mutation.
func TriggerTemplate ¶
func TriggerTemplate(componentID, html string)
TriggerTemplate invokes template hooks with rendered HTML for a component.
func TriggerUnmount ¶
func TriggerUnmount(c Component)
TriggerUnmount invokes unmount lifecycle hooks.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App maintains registered hooks and exposes helper methods for plugins to attach to framework events.
func (*App) RegisterLifecycle ¶
RegisterLifecycle adds hooks for component mount and unmount.
func (*App) RegisterRouter ¶
RegisterRouter adds a router navigation hook.
func (*App) RegisterStore ¶
RegisterStore adds a store mutation hook.
func (*App) RegisterTemplate ¶
RegisterTemplate adds a template render hook.
type Component ¶
type Component interface {
Render() string
Mount()
Unmount()
OnMount()
OnUnmount()
GetName() string
GetID() string
SetSlots(map[string]string)
}
func LoadComponent ¶
LoadComponent retrieves a component by name using the registry. If no component is registered under that name, nil is returned.
type ConditionContent ¶
type ConditionContent struct {
Branches []ConditionalBranchContent
}
type ConditionDependency ¶
type ConditionDependency struct {
// contains filtered or unexported fields
}
type ConditionalBranch ¶
type ConditionalBranchContent ¶
ConditionContent stores rendered content for each branch of a conditional block
type ConditionalNode ¶
type ConditionalNode struct {
Branches []ConditionalBranch
}
func (*ConditionalNode) Render ¶
func (cn *ConditionalNode) Render(c *HTMLComponent) string
Render evaluates the conditional branches and renders the appropriate content.
type HTMLComponent ¶
type HTMLComponent struct {
ID string
Name string
Template string
TemplateFS []byte
Dependencies map[string]Component
Store *state.Store
Props map[string]interface{}
Slots map[string]string
// contains filtered or unexported fields
}
func NewHTMLComponent ¶
func NewHTMLComponent(name string, templateFs []byte, props map[string]interface{}) *HTMLComponent
func (*HTMLComponent) AddDependency ¶
func (c *HTMLComponent) AddDependency(placeholderName string, dep Component)
func (*HTMLComponent) GetID ¶
func (c *HTMLComponent) GetID() string
func (*HTMLComponent) GetName ¶
func (c *HTMLComponent) GetName() string
func (*HTMLComponent) Init ¶
func (c *HTMLComponent) Init(store *state.Store)
func (*HTMLComponent) Mount ¶
func (c *HTMLComponent) Mount()
func (*HTMLComponent) OnMount ¶
func (c *HTMLComponent) OnMount()
func (*HTMLComponent) OnUnmount ¶
func (c *HTMLComponent) OnUnmount()
func (*HTMLComponent) Render ¶
func (c *HTMLComponent) Render() (renderedTemplate string)
func (*HTMLComponent) SetComponent ¶
func (c *HTMLComponent) SetComponent(component Component)
func (*HTMLComponent) SetRouteParams ¶
func (c *HTMLComponent) SetRouteParams(params map[string]string)
func (*HTMLComponent) SetSlots ¶
func (c *HTMLComponent) SetSlots(slots map[string]string)
func (*HTMLComponent) Unmount ¶
func (c *HTMLComponent) Unmount()
type Logger ¶
type Logger interface {
Debug(format string, v ...interface{})
Info(format string, v ...interface{})
Warn(format string, v ...interface{})
Error(format string, v ...interface{})
}
Logger defines logging interface used by the framework.
type Node ¶
type Node interface {
Render(c *HTMLComponent) string
}
AST structures for template parsing