Skip to content

module

html

Mapping DSL elements to HTML: tags, attributes, and string rendering (used for server-side rendering and by the DOM host).

Functions

escape_attr

pub fn escape_attr(s: &str) -> String

s escaped for a double-quoted HTML attribute value.

escape_text

pub fn escape_text(s: &str) -> String

s with &, < and > escaped, for HTML text.

graphics_wrapper_attrs

pub fn graphics_wrapper_attrs(el: &VElement) -> Vec<(String, String)>

The attributes of the element that wraps a drawing surface (canvas2d, scene3d…): its classes, size and accessible name.

host_tag

pub fn host_tag(el: &VElement) -> String

The HTML tag for a DSL element. Unknown names pass through, so plain HTML tags (section, footer, …) work in templates.

html_attributes

pub fn html_attributes(el: &VElement) -> Vec<(String, String)>

HTML attributes (in a stable order) for a non-graphics element.

html_layer_attrs

pub fn html_layer_attrs(h: &VElement, rel: &str) -> Vec<(String, String)>

The DOM attributes of an html element's layer: its own class, style and ARIA, and where it is in the surface.

html_layers

pub fn html_layers(el: &VElement) -> Vec<(&VElement, String)>

A scene's html elements and their paths within it ("2", "1/3").

is_graphics

pub fn is_graphics(tag: &str) -> bool

Whether a DSL element is a drawing surface.

is_svg_tag

pub fn is_svg_tag(tag: &str) -> bool

Whether tag is SVG content (so all its attributes are kept).

is_void

pub fn is_void(html_tag: &str) -> bool

HTML elements that have no closing tag.

needs_runtime

pub fn needs_runtime(roots: &[VNode]) -> bool

Whether a rendered page needs the runtime (wasm) in the browser: it handles events, focuses something, draws on a surface (surfaces prerender empty) or animates. Without any of these, the prerendered HTML is the whole page.

orbit_controls

pub fn orbit_controls(el: &VElement) -> bool

Whether a 3D scene has orbit controls (controls: "orbit").

proxy_style

pub fn proxy_style(r: &Rect, w: f32, h: f32) -> String

Absolute-position CSS for an accessibility proxy, as percentages of the surface's logical w × h, so proxies follow responsive canvases.

rel_path

pub fn rel_path(rel: &str) -> Vec<usize>

"1/3" → [1, 3].

to_html

pub fn to_html(roots: &[VNode]) -> String

Serialise a rendered tree to HTML.

Constants

BASE_CSS

pub const BASE_CSS: &str = …;

Default styles for the built-in layout primitives and graphics proxies.

BOOLEAN

pub const BOOLEAN: &[&str] = _;

HTML attributes written with no value when true, and left out when false.

ORBIT_HINT

pub const ORBIT_HINT: &str = "Drag or use the arrow keys to rotate; plus and minus zoom.";

Attributes for the div wrapping a graphics surface. With a class the surface is sized by CSS; otherwise by its width/height. How to use orbit controls, for assistive technology.

PASSTHROUGH

pub const PASSTHROUGH: &[&str] = _;

HTML attributes written as they are on HTML elements (others are left out, apart from class, style, role, aria-*, data-* and, inside svg, everything).