zena:web-templates

zena
import {…} from 'zena:web-templates';

Classes

HostValue

zena
final class HostValue
Re-exported from zena:web-templates/result.zena

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.

Constructors
zena
new()
#
Properties
zena
handle: externref
#

Event

zena
extension class Event
Re-exported from zena:web-templates/result.zena

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.

Methods
zena
targetValue(): String
#

event.target.value: the text of the input that fired the event.

zena
key(): String
#

event.key of a keyboard event.

zena
preventDefault(): void
#
zena
stopPropagation(): void
#

TemplateResult

zena
final class TemplateResult
Re-exported from zena:web-templates/result.zena

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.

Constructors
zena
new()
#
Properties
zena
strings: TemplateStringsArray
#
zena
values: FixedArray<TemplateValue>
#
zena
kind: i32
#

1 for HTML, 2 for SVG, 3 for MathML.

Type aliases

Listener

zena
type Listener = (event: Event) => void
Re-exported from zena:web-templates/result.zena

An event listener, for an @event=${…} hole.

TemplateValue

zena
type TemplateValue = String | TemplateResult | Iterable<TemplateValue> | Listener | Box<i32> | Box<f64> | Box<boolean> | HostValue | null
Re-exported from zena:web-templates/result.zena

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

zena
function html(strings: TemplateStringsArray, values: FixedArray<TemplateValue>): TemplateResult
Re-exported from zena:web-templates/result.zena

An HTML template.

svg

zena
function svg(strings: TemplateStringsArray, values: FixedArray<TemplateValue>): TemplateResult
Re-exported from zena:web-templates/result.zena

An SVG template, for use inside an <svg> element.

mathml

zena
function mathml(strings: TemplateStringsArray, values: FixedArray<TemplateValue>): TemplateResult
Re-exported from zena:web-templates/result.zena

A MathML template, for use inside a <math> element.

webui_version

zena
function webui_version(): i32
Re-exported from zena:web-templates/protocol.zena

The protocol version this library implements.

webui_result_strings

zena
function webui_result_strings(result: TemplateResult): TemplateStringsArray
Re-exported from zena:web-templates/protocol.zena

webui_result_type

zena
function webui_result_type(result: TemplateResult): i32
Re-exported from zena:web-templates/protocol.zena

webui_strings_count

zena
function webui_strings_count(strings: TemplateStringsArray): i32
Re-exported from zena:web-templates/protocol.zena

webui_strings_at

zena
function webui_strings_at(strings: TemplateStringsArray, index: i32): externref
Re-exported from zena:web-templates/protocol.zena

webui_strings_raw_at

zena
function webui_strings_raw_at(strings: TemplateStringsArray, index: i32): externref
Re-exported from zena:web-templates/protocol.zena

webui_value_count

zena
function webui_value_count(container: anyref): i32
Re-exported from zena:web-templates/protocol.zena

webui_value_kind

zena
function webui_value_kind(container: anyref, index: i32): i32
Re-exported from zena:web-templates/protocol.zena

webui_value_extern

zena
function webui_value_extern(container: anyref, index: i32): externref
Re-exported from zena:web-templates/protocol.zena

The host value of a Text or Host value.

webui_value_ref

zena
function webui_value_ref(container: anyref, index: i32): anyref
Re-exported from zena:web-templates/protocol.zena

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

zena
function webui_value_number(container: anyref, index: i32): f64
Re-exported from zena:web-templates/protocol.zena

The number of a Number value, or 0 or 1 for a Boolean.

webui_listener_invoke

zena
function webui_listener_invoke(listener: anyref, event: externref): void
Re-exported from zena:web-templates/protocol.zena

Calls a listener with the host's event.

Variables

nothing

zena
let nothing: TemplateValue
Re-exported from zena:web-templates/result.zena

The value that renders nothing.