pub struct Attribute { /* private fields */ }Expand description
A single HTML attribute.
Values are escaped when the attribute is built, not when it is rendered — see
crate::core::escape.
§Examples
use winged_rust::core::Attribute;
assert_eq!(Attribute::new("href", "/a?x=1&y=2").to_string(), r#" href="/a?x=1&y=2""#);
assert_eq!(Attribute::boolean("required").to_string(), " required");Implementations§
Source§impl Attribute
impl Attribute
Sourcepub fn new(key: impl Into<String>, value: impl AsRef<str>) -> Self
pub fn new(key: impl Into<String>, value: impl AsRef<str>) -> Self
Creates an attribute, escaping the value.
Sourcepub fn raw(key: impl Into<String>, value: impl Into<String>) -> Self
pub fn raw(key: impl Into<String>, value: impl Into<String>) -> Self
Creates an attribute without escaping the value.
Winged-Swift uses this for the keys it controls itself — Meta’s name,
property, charset and http-equiv are all inserted with escape: false.
Never pass user data here.
Sourcepub fn boolean(key: impl Into<String>) -> Self
pub fn boolean(key: impl Into<String>) -> Self
Creates a boolean attribute, which renders as a bare key.
hidden, checked, required, open, controls, autoplay, muted.
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Whether this attribute renders as a bare key.
Trait Implementations§
impl Eq for Attribute
impl StructuralPartialEq for Attribute
Auto Trait Implementations§
impl Freeze for Attribute
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnsafeUnpin for Attribute
impl UnwindSafe for Attribute
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more