Skip to main content

custom

Macro custom 

custom!() { /* proc-macro */ }
Available on crate features http and html only.
Expand description

Render an HTML element with a runtime-supplied tag name — useful for web components and any other custom element.

// <my-icon size="lg"><span>x</span></my-icon>
custom!("my-icon", size = "lg", span!("x"))

The first argument must be a string literal naming the tag. Subsequent arguments behave exactly like the body of a known-element macro: attributes (name = value / name? = optional) followed by children.

Custom elements are always rendered as containers — there is no “void” form, since web components are by definition non-void. Also note that the macro performs no validation of the tag name; the caller is responsible for picking a name that is legal HTML.