feat(build): add concise render helper

Generate render(view) as the short page/fragment composition helper while keeping render_html(view) as an explicit compatibility alias, then move examples to the leaner happy path.

req: component/003

req: dx/006

req: view/001
This commit is contained in:
slhx agent
2026-06-01 23:09:34 +02:00
parent a8d4604da8
commit 0d4a643759
6 changed files with 28 additions and 25 deletions
+5 -5
View File
@@ -194,7 +194,7 @@ fn all_examples() -> String {
fn shell(body: String) -> String {
// Explicit full-page shell composition boundary for already-rendered hemplate fragments.
// req: html_safety/002 req: view/001 req: component/003
ui::render_html(&AppShell {
ui::render(&AppShell {
body: SafeHtml::trusted(body),
})
.into_string()
@@ -215,7 +215,7 @@ fn todos_view(todos: &[Todo]) -> TodoItems {
fn render_page_swap(title: &'static str, message: &'static str) -> String {
// req: html_safety/002 req: view/001 req: component/003
page_swap::render_html(&PageSwap {
page_swap::render(&PageSwap {
content: render_docs_content(message),
title,
})
@@ -224,7 +224,7 @@ fn render_page_swap(title: &'static str, message: &'static str) -> String {
fn render_docs_content(message: &'static str) -> SafeHtml {
// req: html_safety/002 req: view/001 req: component/003
ui::render_html(&DocsContent { message })
ui::render(&DocsContent { message })
}
#[cfg(test)]
@@ -298,7 +298,7 @@ mod tests {
fn todos_payload_is_rendered_by_a_hemplate_view() {
let todos = vec![Todo { id: 7, title: "<b>Ship v0</b>".to_owned() }];
let html = ui::render_html(&todos_view(&todos));
let html = ui::render(&todos_view(&todos));
let document = Html::parse_fragment(html.as_str());
let rows = document.select(&selector("li[data-key]")).collect::<Vec<_>>();
assert_eq!(rows.len(), 1);
@@ -310,7 +310,7 @@ mod tests {
// req: html_safety/002 req: view/001 req: test/005
#[test]
fn empty_todos_payload_is_rendered_by_a_hemplate_view() {
let html = ui::render_html(&todos_view(&[]));
let html = ui::render(&todos_view(&[]));
let document = Html::parse_fragment(html.as_str());
let rows = document.select(&selector("li")).collect::<Vec<_>>();
assert_eq!(rows.len(), 1);