Struct lol_html::html_content::StartTag
source · pub struct StartTag<'i> { /* private fields */ }
Expand description
An HTML start tag rewritable unit.
Exposes API for examination and modification of a parsed HTML start tag.
Implementations§
source§impl<'i> StartTag<'i>
impl<'i> StartTag<'i>
sourcepub fn name_preserve_case(&self) -> String
pub fn name_preserve_case(&self) -> String
Returns the name of the tag, preserving its case.
sourcepub fn namespace_uri(&self) -> &'static str
pub fn namespace_uri(&self) -> &'static str
Returns the namespace URI of the tag’s element.
sourcepub fn attributes(&self) -> &[Attribute<'i>]
pub fn attributes(&self) -> &[Attribute<'i>]
Returns an immutable collection of tag’s attributes.
sourcepub fn set_attribute(
&mut self,
name: &str,
value: &str
) -> Result<(), AttributeNameError>
pub fn set_attribute( &mut self, name: &str, value: &str ) -> Result<(), AttributeNameError>
Sets value
of tag’s attribute with name
.
If tag doesn’t have an attribute with the name
, method adds a new attribute
to the tag with name
and value
.
sourcepub fn remove_attribute(&mut self, name: &str)
pub fn remove_attribute(&mut self, name: &str)
Removes an attribute with the name
if it is present.
sourcepub fn self_closing(&self) -> bool
pub fn self_closing(&self) -> bool
Whether the tag is explicitly self-closing, e.g. <foo />
.
sourcepub fn before(&mut self, content: &str, content_type: ContentType)
pub fn before(&mut self, content: &str, content_type: ContentType)
Inserts content
before the start tag.
Consequent calls to the method append content
to the previously inserted content.
sourcepub fn after(&mut self, content: &str, content_type: ContentType)
pub fn after(&mut self, content: &str, content_type: ContentType)
Inserts content
after the start tag.
Consequent calls to the method prepend content
to the previously inserted content.
sourcepub fn replace(&mut self, content: &str, content_type: ContentType)
pub fn replace(&mut self, content: &str, content_type: ContentType)
Replaces the start tag with content
.
Consequent calls to the method overwrite previous replacement content.