pub struct Attribute {
pub name: AttributeName,
pub colon: Option<Colon>,
pub value: AttributeValue,
pub comma: Option<Comma>,
pub dyn_idx: DynIdx,
pub el_name: Option<ElementName>,
}
Expand description
A property value in the from of a name: value
pair with an optional comma.
Note that the colon and value are optional in the case of shorthand attributes. We keep them around
to support “lossless” parsing in case that ever might be useful.
Fields§
§name: AttributeName
The name of the attribute (ident or custom)
IE class
or onclick
colon: Option<Colon>
The colon that separates the name and value - keep this for lossless parsing
value: AttributeValue
The value of the attribute
IE class="my-class"
or onclick: move |_| println!("clicked")
comma: Option<Comma>
The comma that separates this attribute from the next one Used for more accurate completions
dyn_idx: DynIdx
The dynamic index of this attribute - used by the template system
el_name: Option<ElementName>
The element name of this attribute if it is bound to an element. When parsed for components or freestanding, this will be None
Implementations§
Source§impl Attribute
impl Attribute
Sourcepub fn from_raw(name: AttributeName, value: AttributeValue) -> Self
pub fn from_raw(name: AttributeName, value: AttributeValue) -> Self
Create a new attribute from a name and value
Sourcepub fn set_dyn_idx(&self, idx: usize)
pub fn set_dyn_idx(&self, idx: usize)
Set the dynamic index of this attribute
Sourcepub fn get_dyn_idx(&self) -> usize
pub fn get_dyn_idx(&self) -> usize
Get the dynamic index of this attribute
pub fn span(&self) -> Span
pub fn as_lit(&self) -> Option<&HotLiteral>
Sourcepub fn with_literal(&self, f: impl FnOnce(&HotLiteral))
pub fn with_literal(&self, f: impl FnOnce(&HotLiteral))
Run this closure against the attribute if it’s hotreloadable