titan_html/
lib.rs

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
#![allow(clippy::to_string_trait_impl)]
#![allow(clippy::inherent_to_string)]
pub mod class;
mod context;
pub mod prelude;
pub mod tags;

pub use titan_html_core::*;

pub use titan_html_derive::{css, global_css};

use context::Context;
use tags::{html::Html, Body, IntoTag};

const DOCTYPE: &str = "<!DOCTYPE html>";

pub fn render(root: Html) -> String {
  let mut body = root.body.into_tag();
  let mut context = Context::from(root.head);
  body.hydrate(&mut context);

  let mut html = Html {
    head: context.into(),
    // Removed by line below
    body: Body::default(),
  }
  .into_tag();
  html.children()[1] = body;

  format!("{}{}", DOCTYPE, html.to_string())
}