go-html/context.go
Claude 3e76e72cb7
feat: add Text node with go-i18n grammar pipeline
Introduces textNode that renders through go-i18n's T() function with
automatic HTML escaping for safe-by-default output. Adds escapeHTML
utility, NewContextWithService for explicit service binding, and
Entitlements field on Context for upcoming conditional rendering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 23:35:50 +00:00

27 lines
648 B
Go

package html
import i18n "forge.lthn.ai/core/go-i18n"
// Context carries rendering state through the node tree.
type Context struct {
Identity string
Locale string
Entitlements func(feature string) bool
Data map[string]any
service *i18n.Service
}
// NewContext creates a new rendering context with sensible defaults.
func NewContext() *Context {
return &Context{
Data: make(map[string]any),
}
}
// 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,
}
}