1#![allow(clippy::to_string_trait_impl)]
2#![allow(clippy::inherent_to_string)]
3pub mod class;
4mod context;
5pub mod prelude;
6pub mod tags;
7
8pub use titan_html_core::*;
9
10pub use titan_html_derive::{css, global_css};
11
12use context::Context;
13use tags::{html::Html, Body, IntoTag};
14
15const DOCTYPE: &str = "<!DOCTYPE html>";
16
17pub fn render(root: Html) -> String {
18 let mut body = root.body.into_tag();
19 let mut context = Context::from(root.head);
20 body.hydrate(&mut context);
21
22 let mut html = Html {
23 head: context.into(),
24 body: Body::default(),
26 with_csp_nonce: root.with_csp_nonce.clone(),
27 }
28 .into_tag();
29 html.children()[1] = body;
30
31 if let Some(nonce) = root.with_csp_nonce {
32 html.apply_nonce(&nonce);
33 }
34 format!("{}{}", DOCTYPE, html.to_string())
35}