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

pub use titan_html_derive::css;

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

pub fn render(mut root: Html) -> String {
  let mut body = root.body.clone().into_tag();

  let mut ctx = Context::default();
  body.hydrate(&mut ctx);
  ctx.mutate_head(&mut root.head);

  let mut root_tag = root.into_tag();
  root_tag.children()[1] = body;

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