Fixed rendering in Rocket with conditional compilation macros. Will raise an issue for Dioxus since this is ultimately their problem.

This commit is contained in:
Ada Werefox 2023-04-06 20:59:19 -05:00
parent 686e591f21
commit fc595e021e

View File

@ -43,9 +43,28 @@ pub mod web_app {
))
}
fn MakePoem(cx: Scope) -> Element {
#[cfg(any(target_family = "unix", target_family = "windows"))]
pub fn RenderPoemElement(cx: Scope) -> Element {
let poem_str = include_str!("../../data/poem.md");
let poem = markdown::to_html(poem_str);
cx.render(rsx!(div {
class: "font-nerd flex flex-col space-y-4 mx-4 py-4",
"{poem}",}))
}
#[cfg(target_family = "wasm")]
pub fn RenderPoemElement(cx: Scope) -> Element {
let poem_str = include_str!("../../data/poem.md");
let poem = markdown::to_html(poem_str);
cx.render(rsx!(div {
class: "font-nerd flex flex-col space-y-4 mx-4 py-4",
dangerous_inner_html: "{poem}"
},))
}
fn MakePoem(cx: Scope) -> Element {
let mut vdom = VirtualDom::new(RenderPoemElement);
let _ = vdom.rebuild();
cx.render(rsx!(
div {
@ -60,10 +79,7 @@ pub mod web_app {
class: "flex justify-center border-4 bg-alice-werefox-grey-lightest dark:bg-alice-werefox-grey-dark border-4 border-alice-werefox-red-dark dark:border-alice-werefox-red text-alice-werefox-red-dark dark:text-alice-werefox-red-light p-4",
"Tell Me More"
},
div {
class: "font-nerd flex flex-col space-y-4 mx-4 py-4",
dangerous_inner_html: "{poem}",
}
RenderPoemElement {},
}
}
))