pub struct Tag<'t, A: Attributes, I: Html, const SILENT: bool> { /* private fields */ }
Expand description
Represents a tag.
TODO better docs
Implementations§
Source§impl<'n, A: Attributes, I: Html, const SILENT: bool> Tag<'n, A, I, SILENT>
impl<'n, A: Attributes, I: Html, const SILENT: bool> Tag<'n, A, I, SILENT>
Sourcepub fn child<C: Html>(self, child: C) -> Tag<'n, A, Sum<I, C>, SILENT>
pub fn child<C: Html>(self, child: C) -> Tag<'n, A, Sum<I, C>, SILENT>
Adds a child to the tag.
§Arguments
child
- The child to add.
§Example
use write_html::*;
use std::fmt::Write;
let mut s = String::new();
s.write_html(tags::div(Empty, Empty)
.child(tags::p(Empty, Empty)
.child("Hello, world!".as_html())
)
).unwrap();
assert_eq!(s, "<div><p>Hello, world!</p></div>");
Sourcepub fn attributes<B: Attributes>(
self,
attributes: B,
) -> Tag<'n, Sum<A, B>, I, SILENT>
pub fn attributes<B: Attributes>( self, attributes: B, ) -> Tag<'n, Sum<A, B>, I, SILENT>
Adds multiple attributes to the tag.
§Arguments
attributes
- The attributes to add.
§Example
use write_html::*;
use std::fmt::Write;
let mut s = String::new();
s.write_html(tags::div(Empty, Empty)
.attributes([
("class", "container"),
("id", "main"),
])
).unwrap();
assert_eq!(s, "<div class=\"container\" id=\"main\"></div>");
Sourcepub fn attr<Name: AttributeName, Value: AttributeValue>(
self,
name: Name,
value: Value,
) -> Tag<'n, Sum<A, [(Name, Value); 1]>, I, SILENT>
pub fn attr<Name: AttributeName, Value: AttributeValue>( self, name: Name, value: Value, ) -> Tag<'n, Sum<A, [(Name, Value); 1]>, I, SILENT>
Adds an attribute to the tag.
Trait Implementations§
Source§impl<'t, A: Clone + Attributes, I: Clone + Html, const SILENT: bool> Clone for Tag<'t, A, I, SILENT>
impl<'t, A: Clone + Attributes, I: Clone + Html, const SILENT: bool> Clone for Tag<'t, A, I, SILENT>
Source§impl<'t, A: Debug + Attributes, I: Debug + Html, const SILENT: bool> Debug for Tag<'t, A, I, SILENT>
impl<'t, A: Debug + Attributes, I: Debug + Html, const SILENT: bool> Debug for Tag<'t, A, I, SILENT>
Source§impl<'t, A: Hash + Attributes, I: Hash + Html, const SILENT: bool> Hash for Tag<'t, A, I, SILENT>
impl<'t, A: Hash + Attributes, I: Hash + Html, const SILENT: bool> Hash for Tag<'t, A, I, SILENT>
Source§impl<'t, A: Ord + Attributes, I: Ord + Html, const SILENT: bool> Ord for Tag<'t, A, I, SILENT>
impl<'t, A: Ord + Attributes, I: Ord + Html, const SILENT: bool> Ord for Tag<'t, A, I, SILENT>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'t, A: PartialEq + Attributes, I: PartialEq + Html, const SILENT: bool> PartialEq for Tag<'t, A, I, SILENT>
impl<'t, A: PartialEq + Attributes, I: PartialEq + Html, const SILENT: bool> PartialEq for Tag<'t, A, I, SILENT>
Source§impl<'t, A: PartialOrd + Attributes, I: PartialOrd + Html, const SILENT: bool> PartialOrd for Tag<'t, A, I, SILENT>
impl<'t, A: PartialOrd + Attributes, I: PartialOrd + Html, const SILENT: bool> PartialOrd for Tag<'t, A, I, SILENT>
impl<'t, A: Copy + Attributes, I: Copy + Html, const SILENT: bool> Copy for Tag<'t, A, I, SILENT>
impl<'t, A: Eq + Attributes, I: Eq + Html, const SILENT: bool> Eq for Tag<'t, A, I, SILENT>
impl<'t, A: Attributes, I: Html, const SILENT: bool> StructuralPartialEq for Tag<'t, A, I, SILENT>
Auto Trait Implementations§
impl<'t, A, I, const SILENT: bool> Freeze for Tag<'t, A, I, SILENT>
impl<'t, A, I, const SILENT: bool> RefUnwindSafe for Tag<'t, A, I, SILENT>where
A: RefUnwindSafe,
I: RefUnwindSafe,
impl<'t, A, I, const SILENT: bool> Send for Tag<'t, A, I, SILENT>
impl<'t, A, I, const SILENT: bool> Sync for Tag<'t, A, I, SILENT>
impl<'t, A, I, const SILENT: bool> Unpin for Tag<'t, A, I, SILENT>
impl<'t, A, I, const SILENT: bool> UnwindSafe for Tag<'t, A, I, SILENT>where
A: UnwindSafe,
I: UnwindSafe,
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