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
use html_rs::{
    elements::{Div, ElementBuilder, TextContent, Title, P},
    Html, HtmlBody, HtmlScript, HtmlStyle,
};

fn main() {
    let title = Title::builder().append_child(TextContent::builder().text("It works!"));
    let style = HtmlStyle::new("body { color: #000000; }");
    let script1 = HtmlScript::new(
        format!(
            r#"console.log("Hello from file {} at line {}")"#,
            file!(),
            line!(),
        )
        .as_str(),
    );

    let div = Div::builder().attr("class", "light-theme").append_child(
        P::builder()
            .attr("class", "light-theme")
            .append_child(TextContent::text("It Works!")),
    );

    let body = HtmlBody::new()
        .set_attr("lang", "en")
        .script(script1)
        .append_child(div);

    let script2 = HtmlScript::new(
        format!(
            r#"console.log("Hello from file {} at line {}")"#,
            file!(),
            line!(),
        )
        .as_str(),
    );
    let html = Html::new()
        .head(title)
        .add_style(style)
        .add_script(script2)
        .body(body);

    #[cfg(feature = "debug")]
    dbg!(&html);

    println!("{html}");
}