Skip to main content

Crate wabot_addon_ui_hypertext

Crate wabot_addon_ui_hypertext 

Source
Expand description

§wabot-addon-ui-hypertext

JSX-shaped views in pure Rust. hypertext’s rsx! macro compiles <div class="x">…</div> into string-pushing code at build time, escapes interpolated values by construction, and — unlike Maud — validates element and attribute names at compile time, so a typo is a build error rather than malformed HTML.

Zero client payload, no build step: same properties as the Maud renderer, different syntax. Pick per project; both satisfy the same ViewBody seam, so the framework doesn’t know which you used.

ⓘ
use hypertext::prelude::*;
use wabot_addon_ui_hypertext::{island_module, IntoView};

#[view("/")]
async fn index(&self) -> UiResult<ViewBody> {
    Ok(rsx! {
        <h1>("Dashboard")</h1>
        (island_module(
            islands::COUNTER_ID, islands::COUNTER_MODULE,
            &CounterProps { start: 3 },
            rsx! { <button>("3")</button> },   // server-rendered fallback
        ))
    }
    .into_view())
}

Interpolation is (expr) rather than {expr} — {} is Rust block syntax, so hypertext uses parentheses for values.

Re-exports§

pub use ::hypertext;

Traits§

IntoView
Turn rendered hypertext markup into the framework’s ViewBody.

Functions§

island
Emit an interactive island.
island_bare
An island with no props.
island_module
Emit an island and declare the module that mounts it, so a page loads only the island bundles it used. Pair with wabot-ui-bundler, which generates both constants from the .island.tsx filename.
link
Set the document title from inside the markup. Declare a <link> that is not a stylesheet — a favicon, a preload.
meta
Set a <meta name=… content=…> pair.
outlet
Placeholder a layout renders where the current view goes. Boosted navigation swaps only this element’s contents, so the shell — and any islands in it — survive.
raw
Splice pre-rendered HTML from elsewhere — a TSX view rendered by the QuickJS runtime, say — into rsx markup.
script
Declare an extra module script this view needs.
style
Declare a stylesheet this view needs.
title
wrap_outlet
Convenience wrapper for the outlet + layout pattern.

Type Aliases§

RawHtml
HTML that rsx! can splice in verbatim. Every helper here returns one, so island hosts and outlets drop straight into markup.