comments

Macro comments 

Source
macro_rules! comments {
    ($selector:expr, $handler:expr) => { ... };
}
Expand description

A convenience macro to construct a rewriting handler for HTML comments in the inner content of an element that can be matched by the specified CSS selector.

§Example

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

let html = rewrite_str(
    r#"<span><!-- 42 --></span>"#,
    RewriteStrSettings {
        element_content_handlers: vec![
            comments!("span", |c| {
                c.set_text("Hello!").unwrap();

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

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

This macro can create either sendable or non-sendable handlers, but not both in a generic context. H: HandlerTypes bound won’t work with this macro.