pub enum Attribute {
String(String),
Fn(Scope, Rc<dyn Fn() -> Attribute + 'static>),
Option(Scope, Option<String>),
Bool(bool),
}
Expand description
Represents the different possible values an attribute node could have.
This mostly exists for the view
macro’s use. You usually won’t need to interact with it directly, but it can be useful for defining
permissive APIs for certain components.
Variants§
String(String)
A plain string value.
Fn(Scope, Rc<dyn Fn() -> Attribute + 'static>)
A (presumably reactive) function, which will be run inside an effect to do targeted updates to the attribute.
Option(Scope, Option<String>)
An optional string value, which sets the attribute to the value if Some
and removes the attribute if None
.
Bool(bool)
A boolean attribute, which sets the attribute if true
and removes the attribute if false
.
Implementations§
source§impl Attribute
impl Attribute
sourcepub fn as_value_string(&self, attr_name: &'static str) -> String
pub fn as_value_string(&self, attr_name: &'static str) -> String
Converts the attribute to its HTML value at that moment, including the attribute name, so it can be rendered on the server.
sourcepub fn as_nameless_value_string(&self) -> Option<String>
pub fn as_nameless_value_string(&self) -> Option<String>
Converts the attribute to its HTML value at that moment, not including the attribute name, so it can be rendered on the server.