Docs
This page was swapped without a full reload.
This page was swapped without a full reload.
This content came from an EffectBatch.
", + ui::page_swap::slots::content.html(render_docs_content( + "This content came from an EffectBatch.", )), ui::page_swap::slots::title.text("Docs"), push("/docs"), @@ -170,7 +173,7 @@ fn all_examples() -> String { ui::todos::lower_html(include_str!("../templates/todos.heml")), ui::wizard::lower_html(include_str!("../templates/wizard.heml")), ui::auth::lower_html(include_str!("../templates/auth.heml")), - ui::page_swap::lower_html(include_str!("../templates/page_swap.heml")), + render_page_swap("Welcome", "Welcome"), ui::notifications::lower_html(include_str!("../templates/notifications.heml")), ] .join("\n") @@ -214,8 +217,25 @@ fn render_todos(todos: &[Todo]) -> SafeHtml { }) } +fn render_page_swap(title: &'static str, message: &'static str) -> String { + // req: html_safety/002 req: view/001 + ui::page_swap::lower_html(render_template(&PageSwap { + content: render_docs_content(message), + title, + })) +} + +fn render_docs_content(message: &'static str) -> SafeHtml { + // req: html_safety/002 req: view/001 + render_html(&DocsContent { message }) +} + fn render_html(template: &impl Hemplate) -> SafeHtml { - SafeHtml::trusted(template.render().expect("v0 hemplate partial renders")) + SafeHtml::trusted(render_template(template)) +} + +fn render_template(template: &impl Hemplate) -> String { + template.render().expect("v0 hemplate view renders") } #[cfg(test)] @@ -227,6 +247,43 @@ mod tests { Selector::parse(value).expect("test selector parses") } + // req: html_safety/002 req: view/001 req: test/005 + #[test] + fn docs_content_payload_is_rendered_by_a_hemplate_view() { + let html = render_docs_content("This content came from an EffectBatch."); + let document = Html::parse_fragment(html.as_str()); + assert_eq!( + document + .select(&selector("h1")) + .next() + .map(|heading| heading.text().collect::{+ self.message +}