zena:web-templates
import {…} from 'zena:web-templates';
Classes
HostValue
final class HostValue
A JavaScript value the module holds without looking inside it, so it
can sit in a template: a DOM node for .node=${…}, a Date for a
child's property. The host hands the value back unchanged.
Event
extension class Event
The event a listener receives: the host's event object, with the capability functions as methods, which are all a module can do with an event unless the host grants more.
An extension class rather than a wrapper, so a listener's event costs no allocation and a method's import is linked only when something calls it: a module whose listeners never read their events imports none of these.
TemplateResult
final class TemplateResult
A template and the values for its holes.
strings is the tagged template's TemplateStringsArray, which the
compiler makes once per call site; that identity is what tells the
host it has seen the template before.
Type aliases
Listener
type Listener = (event: Event) => void
An event listener, for an @event=${…} hole.
TemplateValue
type TemplateValue = String | TemplateResult | Iterable<TemplateValue> | Listener | Box<i32> | Box<f64> | Box<boolean> | HostValue | null
What a hole may hold. A number or boolean arrives boxed: the union
accepts the box, which is what tells the checker to wrap a primitive
interpolation in one. null renders nothing, and an iterable renders
each of its items in turn.
Functions
html
function html(strings: TemplateStringsArray, values: FixedArray<TemplateValue>): TemplateResult
An HTML template.
svg
function svg(strings: TemplateStringsArray, values: FixedArray<TemplateValue>): TemplateResult
An SVG template, for use inside an <svg> element.
mathml
function mathml(strings: TemplateStringsArray, values: FixedArray<TemplateValue>): TemplateResult
A MathML template, for use inside a <math> element.
webui_version
function webui_version(): i32
The protocol version this library implements.
webui_result_strings
function webui_result_strings(result: TemplateResult): TemplateStringsArray
webui_result_type
function webui_result_type(result: TemplateResult): i32
webui_strings_count
function webui_strings_count(strings: TemplateStringsArray): i32
webui_strings_at
function webui_strings_at(strings: TemplateStringsArray, index: i32): externref
webui_strings_raw_at
function webui_strings_raw_at(strings: TemplateStringsArray, index: i32): externref
webui_value_count
function webui_value_count(container: anyref): i32
webui_value_kind
function webui_value_kind(container: anyref, index: i32): i32
webui_value_extern
function webui_value_extern(container: anyref, index: i32): externref
The host value of a Text or Host value.
webui_value_ref
function webui_value_ref(container: anyref, index: i32): anyref
The module object of a Template, List or Listener value. An
iterable is read into an array here, so the host can index it; the
array is handed out once and read with the webui_value_* accessors.
webui_value_number
function webui_value_number(container: anyref, index: i32): f64
The number of a Number value, or 0 or 1 for a Boolean.
webui_listener_invoke
function webui_listener_invoke(listener: anyref, event: externref): void
Calls a listener with the host's event.
Variables
nothing
let nothing: TemplateValue
The value that renders nothing.