lol_html

Macro end

source
macro_rules! end {
    ($handler:expr) => { ... };
}
Expand description

A convenience macro to construct a rewriting handler for the end of the document.

This handler will only be called after the rewriter has finished processing the final chunk.

ยงExample

use lol_html::{rewrite_str, element, end, RewriteStrSettings};
use lol_html::html_content::ContentType;

let html = rewrite_str(
    r#"<span>foo</span>"#,
    RewriteStrSettings {
        element_content_handlers: vec![
            element!("span", |el| {
                el.append("bar", ContentType::Text);

                Ok(())
            })
        ],
        document_content_handlers: vec![
            end!(|end| {
                end.append("<div>baz</div>", ContentType::Html);

                Ok(())
            })
        ],
        ..RewriteStrSettings::new()
    }
).unwrap();

assert_eq!(html, r#"<span>foobar</span><div>baz</div>"#);