1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
//! This crate contains code to build Html Pages
//!
//! # Example
//! ```
//! use rhtml::*;
//!
//! let mut builder = HtmlBuilder::with_title("My page");
//! let body = builder.body();
//! html!("h1", {text: "Hello world!"}).append_to(body);
//! html!("a", {"href": "http://www.web.net"},
//! {text: "My link"}).append_to(body);
//! let page = builder.to_string();
//! ```
mod node;
pub use node::HtmlNode;
mod builder;
pub use builder::HtmlBuilder;
#[macro_export]
macro_rules! html {
($name:literal /* Name of the node */
/* Attributes */
$(, {
$(
$attr:literal : $value:expr
),*
}
)?
/* Functions */
$(, {
$(
$f:ident : $v:expr
),*
}
)?
/* Childs */
$(,
[ $($o:expr),* $(,)? ]
)?
) => {
{
#[allow(unused_mut)]
let mut node = HtmlNode::with_name($name);
$(
$(
node.attr($attr,$value);
)*
)?
$(
$(
node.$f($v);
)*
)?
$(
$(
node.append($o);
)*
)?
node
}
};
}