Server-rendered HTML as plain Text: escaping, element builders, a component layer, and a Tailwind-style utility stylesheet inlined into every page.
Add it to your wo.toml. The
KEY is the module name — that is what use imports.
[deps]
view = { git = "https://github.com/shoneyj/writeonce-view", rev = "v0.1.0" }esc() — escapes & < > ". A {{ }} hole in a raw text literal compiles to a call to it, so display data is escaped by construction. (Written with entities here: inside a raw literal, a real {{ would BE a hole.)Component — a class with fields and fn render() -> Text, satisfied structurally. multi Component holds children directly; render_all renders them in order.Layout — content projection: title, head, nav, content and footer as pre-rendered slots.el, link, card, nav_bar, code_block, form_post, text_input, text_area, submit_btn, btn_link.tw_css() + page() — one hand-written utility sheet, inlined, so a page is one self-contained response. No CDN, no build step, no JS.use view
class Card {
name: Text
fn render() -> Text {
return `
<div class="card">
<h3>{{ self.name }}</h3>
</div>`;
}
}
-- in a handler:
let c = Card { name: user_supplied };
return ok_html(page("Hello", c.render()));