Function css_image::render

source ·
pub fn render<T>(css: T) -> Result<HashMap<String, Vec<u8>>, CssError<'static>>
where T: Parseable,
Expand description

Render images with CSS

§Examples

use css_image::{render, parse};

let css = r#"
body {
   background-color: #FFFFFF;
   width: 100px;
   height: 100px;
}
"#;

let result = render(css); // HashMap of selector name -> image data
assert!(result.is_ok());

let mut styles = parse(css).unwrap(); // Parse the CSS into a Styles struct for easier manipulation
styles.get_mut("body").unwrap().content = Some("Hello, World!".to_string()); // Change the content of the body element

let result = render(styles); // HashMap of selector name -> image data
assert!(result.is_ok());