Macro lol_html::doc_text[][src]

macro_rules! doc_text {
    ($handler:expr) => { ... };
}

A convenience macro to construct a rewriting handler for all text chunks in the HTML document.

Example

use lol_html::{rewrite_str, doc_text, RewriteStrSettings};
use lol_html::html_content::ContentType;

let html = rewrite_str(
    r#"Hello<span>Hello</span>Hello"#,
    RewriteStrSettings {
        document_content_handlers: vec![
            doc_text!(|t| {
                if t.last_in_text_node() {
                    t.after(" world", ContentType::Text);
                }

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

assert_eq!(html, r#"Hello world<span>Hello world</span>Hello world"#);