html_node/
macros.rs

1/// Creates a [`Node::Comment`][crate::Node::Comment].
2#[macro_export]
3macro_rules! comment {
4    ($($tt:tt)*) => {
5        ::html_node::Node::Comment(::html_node::Comment {
6            comment: ::std::format!($($tt)*),
7        })
8    };
9}
10
11/// Creates a [`Node::Text`][crate::Node::Text].
12#[macro_export]
13macro_rules! text {
14    ($($tt:tt)*) => {
15        ::html_node::Node::Text(::html_node::Text {
16            text: ::std::format!($($tt)*),
17        })
18    };
19}
20
21/// Creates a [`Node::UnsafeText`][crate::Node::UnsafeText].
22///
23/// # Warning
24///
25/// [`Node::UnsafeText`][crate::Node::UnsafeText] is not escaped when rendered,
26/// and as such, can allow for XSS attacks. Use with caution!
27#[macro_export]
28macro_rules! unsafe_text {
29    ($($tt:tt)*) => {
30        ::html_node::Node::UnsafeText(::html_node::UnsafeText {
31            text: ::std::format!($($tt)*),
32        })
33    };
34}