2026-02-16 23:34:27 +00:00
|
|
|
package html
|
|
|
|
|
|
2026-02-16 23:35:50 +00:00
|
|
|
import i18n "forge.lthn.ai/core/go-i18n"
|
|
|
|
|
|
2026-02-16 23:34:27 +00:00
|
|
|
// Context carries rendering state through the node tree.
|
|
|
|
|
type Context struct {
|
2026-02-16 23:35:50 +00:00
|
|
|
Identity string
|
|
|
|
|
Locale string
|
|
|
|
|
Entitlements func(feature string) bool
|
|
|
|
|
Data map[string]any
|
|
|
|
|
service *i18n.Service
|
2026-02-16 23:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewContext creates a new rendering context with sensible defaults.
|
|
|
|
|
func NewContext() *Context {
|
|
|
|
|
return &Context{
|
|
|
|
|
Data: make(map[string]any),
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-16 23:35:50 +00:00
|
|
|
|
|
|
|
|
// NewContextWithService creates a rendering context backed by a specific i18n service.
|
|
|
|
|
func NewContextWithService(svc *i18n.Service) *Context {
|
|
|
|
|
return &Context{
|
|
|
|
|
Data: make(map[string]any),
|
|
|
|
|
service: svc,
|
|
|
|
|
}
|
|
|
|
|
}
|