pub struct HtmlElement { /* private fields */ }Expand description
A structure representing HTML element.
Implementations§
Source§impl HtmlElement
impl HtmlElement
pub fn no_indent(self) -> Self
pub fn hide_closing_tag(self) -> Self
pub fn always_expand(self) -> Self
Sourcepub fn set_attribute<N, V>(&mut self, name: N, value: V)
pub fn set_attribute<N, V>(&mut self, name: N, value: V)
Sets an attribute of the HTML element.
Sourcepub fn child(self, child: impl Into<HtmlElement>) -> Self
pub fn child(self, child: impl Into<HtmlElement>) -> Self
Adds a child element.
Sourcepub fn add_child(&mut self, child: impl Into<HtmlElement>)
pub fn add_child(&mut self, child: impl Into<HtmlElement>)
Adds a child element.
Sourcepub fn opt_child(self, opt_child: Option<HtmlElement>) -> Self
pub fn opt_child(self, opt_child: Option<HtmlElement>) -> Self
Adds an optional child element.
Sourcepub fn add_opt_child(&mut self, opt_child: Option<HtmlElement>)
pub fn add_opt_child(&mut self, opt_child: Option<HtmlElement>)
Adds an optional child element.
Sourcepub fn children(self, children: &[HtmlElement]) -> Self
pub fn children(self, children: &[HtmlElement]) -> Self
Adds multiple children elements.
Sourcepub fn add_children(&mut self, children: &[HtmlElement])
pub fn add_children(&mut self, children: &[HtmlElement])
Adds multiple children elements.
Sourcepub fn set_content(&mut self, content: &str)
pub fn set_content(&mut self, content: &str)
Sets the content of the HTML element.
Source§impl HtmlElement
Implementation of commonly used HTML elements.
impl HtmlElement
Implementation of commonly used HTML elements.
Sourcepub fn h1(content: &str) -> Self
pub fn h1(content: &str) -> Self
Creates <h1> HTML element. The section heading level 1 element.
§Example
let h = HtmlElement::h1("Heading level 1");
assert_eq!("<h1>Heading level 1</h1>", h.to_string());Sourcepub fn h2(content: &str) -> Self
pub fn h2(content: &str) -> Self
Creates <h2> HTML element. The section heading level 2 element.
§Example
let h = HtmlElement::h2("Heading level 2");
assert_eq!("<h2>Heading level 2</h2>", h.to_string());Sourcepub fn h3(content: &str) -> Self
pub fn h3(content: &str) -> Self
Creates <h3> HTML element. The section heading level 3 element.
§Example
let h = HtmlElement::h3("Heading level 3");
assert_eq!("<h3>Heading level 3</h3>", h.to_string());Sourcepub fn h4(content: &str) -> Self
pub fn h4(content: &str) -> Self
Creates <h4> HTML element. The section heading level 4 element.
§Example
let h = HtmlElement::h4("Heading level 4");
assert_eq!("<h4>Heading level 4</h4>", h.to_string());Sourcepub fn h5(content: &str) -> Self
pub fn h5(content: &str) -> Self
Creates <h5> HTML element. The section heading level 5 element.
§Example
let h = HtmlElement::h5("Heading level 5");
assert_eq!("<h5>Heading level 5</h5>", h.to_string());Sourcepub fn h6(content: &str) -> Self
pub fn h6(content: &str) -> Self
Creates <h6> HTML element. The section heading level 6 element.
§Example
let h = HtmlElement::h6("Heading level 6");
assert_eq!("<h6>Heading level 6</h6>", h.to_string());Sourcepub fn br() -> Self
pub fn br() -> Self
Creates <br> HTML element. The line break element.
§Example
let br = HtmlElement::br();
assert_eq!("<br/>", br.to_string());Sourcepub fn div() -> Self
pub fn div() -> Self
Creates <div> HTML element. The content division element.
§Example
let div = HtmlElement::div();
assert_eq!("<div></div>", div.to_string());Sourcepub fn span() -> Self
pub fn span() -> Self
Creates <span> HTML element. The content span element.
§Example
let span = HtmlElement::span();
assert_eq!("<span></span>", span.to_string());Trait Implementations§
Source§impl Clone for HtmlElement
impl Clone for HtmlElement
Source§fn clone(&self) -> HtmlElement
fn clone(&self) -> HtmlElement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HtmlElement
impl Debug for HtmlElement
Source§impl Display for HtmlElement
impl Display for HtmlElement
Source§impl From<&HtmlBodyElement> for HtmlElement
impl From<&HtmlBodyElement> for HtmlElement
Source§fn from(value: &HtmlBodyElement) -> Self
fn from(value: &HtmlBodyElement) -> Self
Converts a reference to HtmlBodyElement into HtmlElement.
Source§impl From<HtmlBodyElement> for HtmlElement
impl From<HtmlBodyElement> for HtmlElement
Source§fn from(value: HtmlBodyElement) -> Self
fn from(value: HtmlBodyElement) -> Self
Converts HtmlBodyElement into HtmlElement.
Source§impl From<HtmlHeadElement> for HtmlElement
impl From<HtmlHeadElement> for HtmlElement
Source§fn from(value: HtmlHeadElement) -> Self
fn from(value: HtmlHeadElement) -> Self
Source§impl From<HtmlLinkElement> for HtmlElement
impl From<HtmlLinkElement> for HtmlElement
Source§fn from(value: HtmlLinkElement) -> Self
fn from(value: HtmlLinkElement) -> Self
Source§impl From<HtmlStyleElement> for HtmlElement
impl From<HtmlStyleElement> for HtmlElement
Source§fn from(value: HtmlStyleElement) -> Self
fn from(value: HtmlStyleElement) -> Self
Source§impl From<SvgDocument> for HtmlElement
impl From<SvgDocument> for HtmlElement
Source§fn from(value: SvgDocument) -> Self
fn from(value: SvgDocument) -> Self
Creates HtmlElement from SvgDocument.