pub struct StyleAttribute<'i> {
    pub declarations: DeclarationBlock<'i>,
    /* private fields */
}
Expand description

An inline style attribute, as in HTML or SVG.

Style attributes can be parsed from a string, minified and transformed for a set of target browsers, and serialied to a string.

Example

use lightningcss::stylesheet::{
  StyleAttribute, ParserOptions, MinifyOptions, PrinterOptions
};

// Parse a style sheet from a string.
let mut style = StyleAttribute::parse(
  "color: yellow; font-family: 'Helvetica';",
  ParserOptions::default()
).unwrap();

// Minify the stylesheet.
style.minify(MinifyOptions::default());

// Serialize it to a string.
let res = style.to_css(PrinterOptions::default()).unwrap();
assert_eq!(res.code, "color: #ff0; font-family: Helvetica");

Fields§

§declarations: DeclarationBlock<'i>

The declarations in the style attribute.

Implementations§

Parses a style attribute from a string.

Minify and transform the style attribute for the provided browser targets.

Serializes the style attribute to a CSS string.

Trait Implementations§

The types of values contained within this value and its children. This is used to skip branches that don’t have any values requested by the Visitor. Read more
Visit the children of this value.
Visits the value by calling an appropriate method on the Visitor. If no corresponding visitor method exists, then the children are visited. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type for metadata in pointers and references to Self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.