Skip to main content

Crate lol_async

Crate lol_async 

Source
Expand description

Async wrapper for cloudflare/lol-html.

use lol_async::html::{element, html_content::ContentType, send::Settings};

let input = Cursor::new(
    "<html><head><title>hello lol</title></head><body><h1>hey there</h1></body></html>",
);

let mut reader = lol_async::rewrite(
    input,
    Settings::new_send().append_element_content_handler(element!("h1", |el| {
        el.append("<span>this was inserted</span>", ContentType::Html);
        Ok(())
    })),
);

let mut buf = String::new();
reader.read_to_string(&mut buf).await?;

assert_eq!(
    buf,
    "<html><head><title>hello lol</title></head><body><h1>hey there<span>this was \
     inserted</span></h1></body></html>"
);

Re-exports§

pub use lol_html as html;

Structs§

Rewriter
An AsyncRead adapter that streams rewritten HTML.

Functions§

rewrite
Creates an AsyncRead that streams HTML rewritten according to the provided Settings.

Type Aliases§

Settings
Settings for Sendable HtmlRewriters.