Macro lol_html::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::default()
    }
).unwrap();

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