`).
/// - `after_closing_body_tag`: The content following the closing `` tag.
///
/// These fields are not explicitly exposed as part of the API, but are critical for dioxus-fullstack
/// to properly inject server-rendered content and client-side bootstrapping scripts into the HTML.
///
/// The simplest HTML document that satisfies this structure is:
///
/// ```html
///
///
///
///
///
///
/// ```
#[derive(Clone, Debug)]
pub struct IndexHtml {
pub(crate) head_before_title: String,
pub(crate) head_after_title: String,
pub(crate) title: String,
pub(crate) close_head: String,
pub(crate) post_main: String,
pub(crate) after_closing_body_tag: String,
}
impl IndexHtml {
/// Create a new `IndexHtml` from the raw contents of an `index.html` file.
///
/// This function will parse the `index.html` and split it into sections for easier manipulation.
/// The `root_id` parameter specifies the id of the main application container (e.g., "main")
/// which your app will render into.
pub fn new(contents: &str, root_id: &str) -> Result
{
let (pre_main, post_main) = contents.split_once(&format!("id=\"{root_id}\""))
.with_context(|| format!("Failed to find id=\"{root_id}\" in index.html. The id is used to inject the application into the page."))?;
let post_main = post_main.split_once('>').with_context(|| {
format!("Failed to find closing > after id=\"{root_id}\" in index.html.")
})?;
let (pre_main, post_main) = (
pre_main.to_string() + &format!("id=\"{root_id}\"") + post_main.0 + ">",
post_main.1.to_string(),
);
let (head, close_head) = pre_main.split_once("").with_context(|| {
format!("Failed to find closing tag after id=\"{root_id}\" in index.html.")
})?;
let (head, close_head) = (head.to_string(), "".to_string() + close_head);
let (post_main, after_closing_body_tag) =
post_main.split_once("