diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index 0db09f8..7ae51f4 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -76,7 +76,7 @@ slhx competes with React by making frontend frameworks unnecessary for most apps 005 Error messages must explain fixes in author language, not internal language. Say “add `h-key="todo.id"` to this `h-for`”, not “missing ScopeKey for ResourceRef”. ### req: dx/006 -006 Generated resource methods are the preferred authoring API: `slots::todo_list.render(view)`, `slots::card.replace(key, view)`, `slots::count.text(42)`, `atoms::user.set(user)`. The public facade and generated view modules expose `render(view)` for trusted hemplate-to-`SafeHtml` page and fragment composition, `static_fragment(include_str!(...))` for prototype/static `.heml` fragments that need generated resource lowering as `SafeHtml`, plus `lower(html)` for callers that need the lowered string; `render_html(view)` and `lower_html(html)` remain explicit compatibility aliases. These return `impl IntoEffect`, `SafeHtml`, or lowered HTML at the boundary. Raw `Effect` constructors, opcodes, and `EffectWriter` remain low-level. [north_star] +006 Generated resource methods are the preferred authoring API: `slots::todo_list.html(ui::render(&view))`, `slots::card.replace(key, view)`, `slots::count.text(42)`, `atoms::user.set(user)`. The public facade and generated view modules expose `render(view)` for trusted hemplate-to-`SafeHtml` page and fragment composition, `static_fragment(include_str!(...))` for prototype/static `.heml` fragments that need generated resource lowering as `SafeHtml`, plus `lower(html)` for callers that need the lowered string; `render_html(view)` and `lower_html(html)` remain explicit compatibility aliases. These return `impl IntoEffect`, `SafeHtml`, or lowered HTML at the boundary. Raw `Effect` constructors, opcodes, and `EffectWriter` remain low-level. [north_star] ### req: dx/007 007 Tuple composition of `IntoEffect` is the canonical batch syntax: `(a, b, c)` implements `IntoEffect` up to arity 12. `Effect::batch((...))` is available but not required for the happy path. diff --git a/examples/kanban.md b/examples/kanban.md index 5418634..1760347 100644 --- a/examples/kanban.md +++ b/examples/kanban.md @@ -240,7 +240,7 @@ pub fn apply_board_patch( PatchResult::Conflict { canonical_board } => Effect::batch(( Effect::set(atoms::BOARD, canonical_board.clone()), - slots::board.render(&BoardView::from(canonical_board)), + slots::board.html(ui::render(&BoardView::from(canonical_board))), )), } } diff --git a/examples/kanban/src/lib.rs b/examples/kanban/src/lib.rs index 5e86bfa..98b7c30 100644 --- a/examples/kanban/src/lib.rs +++ b/examples/kanban/src/lib.rs @@ -6,7 +6,7 @@ mod tests { use super::ui::{board, board_card}; use hemplate::Hemplate; use scraper::{Html, Selector}; - use slhx::{Effect, IntoEffect, Payload, RenderSlotExt}; + use slhx::{Effect, IntoEffect, Payload}; use slhx_test::inspect; #[derive(Hemplate)] @@ -27,7 +27,7 @@ mod tests { #[test] fn kanban_board_updates_generated_slot() { fn render_board() -> impl IntoEffect { - board::slots::board.render(&empty_board()) + board::slots::board.html(slhx::render(&empty_board())) } let effect = inspect(render_board()); diff --git a/examples/techdemo/src/lib.rs b/examples/techdemo/src/lib.rs index 07bf7d0..3a8f366 100644 --- a/examples/techdemo/src/lib.rs +++ b/examples/techdemo/src/lib.rs @@ -7,7 +7,7 @@ mod tests { use super::ui::issue_card::handles as card_handles; use super::ui::issue_lane::events as lane_events; use hemplate::Hemplate; - use slhx::{Effect, IntoEffect, Payload, RenderSlotExt}; + use slhx::{Effect, IntoEffect, Payload}; use slhx_test::inspect; #[derive(Hemplate)] @@ -30,7 +30,7 @@ mod tests { fn techdemo_uses_generated_slots_for_multi_target_updates() { fn update() -> impl IntoEffect { ( - slots::hero_metrics.render(&FastMetric { label: "fast" }), + slots::hero_metrics.html(slhx::render(&FastMetric { label: "fast" })), slots::notice.text("typed"), ) } diff --git a/examples/v0/src/lib.rs b/examples/v0/src/lib.rs index 9a187ad..d65d029 100644 --- a/examples/v0/src/lib.rs +++ b/examples/v0/src/lib.rs @@ -5,7 +5,7 @@ pub mod ui {} mod tests { use super::ui::{auth, counter, notifications, page_swap, todos, wizard}; use hemplate::Hemplate; - use slhx::{push, Effect, IntoEffect, NavigateMode, Payload, RenderKeyedSlotExt, RenderSlotExt}; + use slhx::{push, Effect, IntoEffect, NavigateMode, Payload, RenderKeyedSlotExt}; use slhx_test::inspect; #[derive(Clone, Debug)] @@ -121,9 +121,9 @@ mod tests { fn page_swap_updates_content_and_history() { fn load_docs() -> impl IntoEffect { ( - page_swap::slots::content.render(&DocsContent { + page_swap::slots::content.html(slhx::render(&DocsContent { message: "This page was swapped.", - }), + })), page_swap::slots::title.text("Docs"), push("/docs"), ) diff --git a/slhx-test/tests/examples_contract.rs b/slhx-test/tests/examples_contract.rs index 2468f32..155311f 100644 --- a/slhx-test/tests/examples_contract.rs +++ b/slhx-test/tests/examples_contract.rs @@ -116,6 +116,7 @@ fn canonical_example_docs_do_not_teach_low_level_plumbing() { "lower_html(", "render_html(", "SafeHtml::trusted", + ".render(&", ]; let mut failures = Vec::new(); scan_examples(&examples, &mut |path, text| {