Documentation
¶
Overview ¶
Package jid provides request-scoped JaWS element identifiers and HTML-writing helpers.
Index ¶
Constants ¶
const Invalid = Jid(-1)
Invalid is the canonical invalid Jid returned by the parsers when text does not contain a valid Jid.
Invalid is exactly Jid(-1); the parsers never return any other negative value. Jid.IsValid accepts the broader range j >= 0, so any other negative Jid is reported invalid by IsValid but is not equal to Invalid.
const Prefix = "Jid."
Prefix prefixes HTML IDs based on Jid values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Jid ¶
type Jid int64
Jid is the basis for the HTML id attribute for a UI element within an active request.
It is request-scoped, meaning Jid(1) in one request is not the same element as Jid(1) in another request.
func ParseInt ¶
ParseInt parses a Jid integer and returns it as a Jid.
Returns Invalid if s is not a valid Jid integer or an error occurs.
func ParseString ¶
ParseString parses a canonical unquoted Jid string.
For example, `Jid.2` returns Jid(2). An empty string parses to Jid(0), the whole-request id. Non-empty input must contain Prefix followed by a positive base-10 integer with no sign or leading zero. All other input returns Invalid.
func (Jid) Append ¶
Append appends the unquoted string format of the Jid.
Only positive Jids are appended; Jid(0) (the whole-request id) and negative/invalid Jids append nothing, matching Jid.AppendInt.
func (Jid) AppendInt ¶
AppendInt appends the text format of the Jid's numerical value.
The value is appended only for positive Jids; Jid(0) (the whole-request id) and negative/invalid Jids append nothing.
func (Jid) AppendQuote ¶
AppendQuote appends the string format of the Jid surrounded by double quotes.
Only positive Jids have content between the quotes; Jid(0) (the whole-request id) and negative/invalid Jids yield an empty quoted string ("").
func (Jid) AppendStartTagAttr ¶
AppendStartTagAttr appends `<startTag` followed by the quoted Jid as an HTML id attribute when jid is positive (Jid(0) and negative/invalid Jids append only the start tag, following the same positive-only rule as Jid.AppendQuote).
startTag must be a trusted, syntactically valid HTML tag name: it is written verbatim with no escaping or validation and MUST NOT be derived from untrusted user data, or it becomes an HTML-injection primitive. The numeric Jid itself is always safe.
func (Jid) IsValid ¶
IsValid reports whether jid can identify an element or the request as a whole.
Jid(0) is valid — it is the whole-request id — yet Jid.String and the append helpers render it as empty, so a valid Jid does not always produce a non-empty id string.