API reference
GD.html
Entry for HTML entities, tags, and templates with context-sensitive escaping for text, attributes, URLs, styles, and scripts.
Methods
fill(tpl: String, data: Dictionary, partials: Dictionary = { }) -> String, Errtemplate(tpl: String, partials: Dictionary = { }) -> GDHTMLTemplate, Errattr(value: String) -> Stringtag(name: String, body: String, attrs: Dictionary = { }) -> Stringescape(text: String) -> Stringunescape(text: String) -> Stringescape_async(text: String) -> await Stringunescape_async(text: String) -> await Stringattr_async(value: String) -> await Stringtag_async(name: String, body: String, attrs: Dictionary = { }) -> await Stringfill_async(tpl: String, data: Dictionary, partials: Dictionary = { }) -> await String, Err
fill
fill(tpl: String, data: Dictionary, partials: Dictionary = { }) -> String, ErrRender template source with a dictionary in one call. Use template() and execute() when the same template is rendered repeatedly.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
tpl | String | Required | Template source. |
data | Dictionary | Required | Values for template expressions. |
partials | Dictionary | { } | Named template fragments. |
Return value
String, Err
Rendered text.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
Parsing or rendering failures return Err.
See also
template
template(tpl: String, partials: Dictionary = { }) -> GDHTMLTemplate, ErrParse a template once and reuse the returned object for repeated rendering. This separates template construction errors from per-render data errors.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
tpl | String | Required | Template source text. |
partials | Dictionary | { } | Named template fragments available during rendering. |
Return value
GDHTMLTemplate, Err
A reusable GDHTMLTemplate.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
Invalid template syntax returns Err.
See also
attr
attr(value: String) -> StringEscape an HTML attribute value safely.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value | String | Required | Value to store, serialize, validate or pass to the operation described above. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
tag
tag(name: String, body: String, attrs: Dictionary = { }) -> StringBuild an HTML tag from its name, body, and attributes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | String | Required | Name used to register or look up the corresponding entry. |
body | String | Required | Content to write or include in the response. |
attrs | Dictionary | { } | Named attributes to encode in markup or document metadata. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
escape
escape(text: String) -> StringEscape HTML text.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
unescape
unescape(text: String) -> StringDecode HTML entities into text.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
escape_async
escape_async(text: String) -> await StringDispatch HTML processing to CPU workers.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
await String
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
unescape_async
unescape_async(text: String) -> await StringDispatch HTML entity decoding to a CPU worker.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
await String
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
attr_async
attr_async(value: String) -> await StringDispatch HTML attribute escaping to a CPU worker.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value | String | Required | Value to store, serialize, validate or pass to the operation described above. |
Return value
await String
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
tag_async
tag_async(name: String, body: String, attrs: Dictionary = { }) -> await StringDispatch HTML tag construction to a CPU worker.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | String | Required | Name used to register or look up the corresponding entry. |
body | String | Required | Content to write or include in the response. |
attrs | Dictionary | { } | Named attributes to encode in markup or document metadata. |
Return value
await String
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
fill_async
fill_async(tpl: String, data: Dictionary, partials: Dictionary = { }) -> await String, ErrRender template source with a dictionary in one call. Use template() and execute() when the same template is rendered repeatedly.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
tpl | String | Required | Template source. |
data | Dictionary | Required | Values for template expressions. |
partials | Dictionary | { } | Named template fragments. |
Return value
await String, Err
Rendered text.
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
Parsing or rendering failures return Err.