Documentation
¶
Overview ¶
Package tag expands JaWS tag values into the comparable keys used to find elements during dirtying, broadcasts and event routing.
Index ¶
- Variables
- func FindTagGetter(x any) (path string, tgType reflect.Type, found bool)
- func MustTagExpand(ctx Context, tag any) []any
- func NewErrNotComparable(x any) error
- func NewErrNotUsableAsTag(x any) error
- func TagExpand(ctx Context, tag any) ([]any, error)
- func TagString(tag any) string
- type Context
- type Tag
- type TagGetter
Constants ¶
This section is empty.
Variables ¶
var ErrIllegalTagType errIllegalTagType
ErrIllegalTagType is returned when a UI tag type is disallowed.
var ErrNotComparable errNotComparable
ErrNotComparable is returned when a UI object or tag is not comparable.
var ErrNotUsableAsTag errNotUsableAsTag
ErrNotUsableAsTag is returned when a value cannot be used as a tag.
It is also matchable as ErrNotComparable for backwards compatibility.
var ErrTooManyTags = errTooManyTags{}
ErrTooManyTags is returned when tag expansion exceeds the recursion or result limits.
Functions ¶
func FindTagGetter ¶
FindTagGetter searches x recursively for a nested TagGetter.
func MustTagExpand ¶
MustTagExpand calls TagExpand and either logs or panics if expansion fails.
When ctx is non-nil, expansion errors are passed to [Context.MustLog] and the partial result is returned. When ctx is nil, MustTagExpand panics.
func NewErrNotComparable ¶
NewErrNotComparable returns ErrNotComparable if x is not comparable.
func NewErrNotUsableAsTag ¶
NewErrNotUsableAsTag returns ErrNotUsableAsTag if x cannot be used as a tag.
func TagExpand ¶
TagExpand expands tag into a flat list of unique comparable tag values.
tag may be nil, a Tag, a slice of tags, a TagGetter or another comparable value. Primitive HTML/value types are rejected with ErrIllegalTagType to catch common accidental tags.
Types ¶
type Context ¶
type Context interface {
// Initial returns the Request's initial HTTP request, or nil.
Initial() (r *http.Request)
// Get returns the JaWS session value for the key, or nil.
Get(key string) any
// Set sets the JaWS session value for the key.
Set(key string, value any)
// Context returns the Request's context.
Context() (ctx context.Context)
// Log sends an error to the Logger set in the Jaws.
// Has no effect if the err is nil or the Logger is nil.
// Returns err.
Log(err error) error
// MustLog sends an error to the Logger set in the Jaws or
// panics with the given error if no Logger is set.
// Has no effect if the err is nil.
MustLog(err error)
}
Context is the request state made available while expanding tags.