pub enum TemplateNode<'a> {
    Element {
        tag: &'a str,
        namespace: Option<&'a str>,
        attrs: &'a [TemplateAttribute<'a>],
        children: &'a [TemplateNode<'a>],
    },
    Text {
        text: &'a str,
    },
    Dynamic {
        id: usize,
    },
    DynamicText {
        id: usize,
    },
}
Expand description

A statically known node in a layout.

This can be created at compile time, saving the VirtualDom time when diffing the tree

Variants§

§

Element

Fields

§tag: &'a str

The name of the element

IE for a div, it would be the string “div”

§namespace: Option<&'a str>

The namespace of the element

In HTML, this would be a valid URI that defines a namespace for all elements below it SVG is an example of this namespace

§attrs: &'a [TemplateAttribute<'a>]

A list of possibly dynamic attribues for this element

An attribute on a DOM node, such as id="my-thing" or href="https://example.com".

§children: &'a [TemplateNode<'a>]

A list of template nodes that define another set of template nodes

An statically known element in the dom.

In HTML this would be something like <div id="123"> </div>

§

Text

Fields

§text: &'a str

The actual text

This template node is just a piece of static text

§

Dynamic

Fields

§id: usize

The index of the dynamic node in the VNode’s dynamic_nodes list

This template node is unknown, and needs to be created at runtime.

§

DynamicText

Fields

§id: usize

The index of the dynamic node in the VNode’s dynamic_nodes list

This template node is known to be some text, but needs to be created at runtime

This is separate from the pure Dynamic variant for various optimizations

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.