pub struct Element { /* private fields */ }Expand description
An HTML element with tag, attributes, and children.
Implementations§
Source§impl Element
impl Element
Sourcepub fn attr(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn attr(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add an attribute to this element.
Sourcepub fn bool_attr(self, name: impl Into<String>) -> Self
pub fn bool_attr(self, name: impl Into<String>) -> Self
Add a boolean attribute (no value, e.g., disabled, checked).
Sourcepub fn class(self, class: impl Into<String>) -> Self
pub fn class(self, class: impl Into<String>) -> Self
Add a class attribute. If class already exists, appends to it.
Sourcepub fn child<F>(self, tag: impl Into<String>, f: F) -> Self
pub fn child<F>(self, tag: impl Into<String>, f: F) -> Self
Add a child element using a builder function.
Sourcepub fn when<F>(self, condition: bool, f: F) -> Selfwhere
F: FnOnce(Self) -> Self,
pub fn when<F>(self, condition: bool, f: F) -> Selfwhere
F: FnOnce(Self) -> Self,
Conditionally add content.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more