writeonce/docs/examples/shop/orders/view.wo
shoney.arickathil 0b2a5ebc32 feat(shop): the program template — MVC on disk; story 37 redirected
- docs/examples/shop: types.wo model, per-feature view modules
  (render() classes), root controller files, layout shell/header/
  footer, static assets controller + real style.css, README with
  Angular file map + run + DX referendum notes
- buy flow proven by hand: stock check/decrement, 409s, traversal
  404, css typed, WAL-durable; builds on the UNPATCHED toolchain
- two language gaps recorded, not fixed (per directive): pub+@table
  cannot combine (controllers forced into root module); @view
  projection classes absent
- story 37 REDIRECTED per Vue-SFC review: view.html compiled by woc
  ({{}} auto-escaped, w:if/w:for, typed against view class, no
  runtime engine); render()-as-concatenation failed the referendum;
  forks revised; shop named the acceptance consumer

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 23:57:44 +02:00

44 lines
1.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- orders/view.wo — the confirmation page and the orders table.
use html
pub class OrderOk {
name: Text
qty: Int
total: Float
fn render() -> Text {
let head = el("h1", "", "Order placed");
let what = el("p", "", "${self.qty} × ${esc(self.name)} — total € ${self.total}");
let links = el("p", "", link("/orders", "", "See all orders") .. " · " .. link("/", "", "Keep shopping"));
return el("div", "card", head .. what .. links);
}
}
pub class OrderRow {
name: Text
qty: Int
total: Float
status: Text
fn render() -> Text {
let cells = el("td", "", esc(self.name));
cells = cells .. el("td", "", "${self.qty}");
cells = cells .. el("td", "", "€ ${self.total}");
cells = cells .. el("td", "", esc(self.status));
return el("tr", "", cells);
}
}
pub class OrdersPage {
rows: Text
fn render() -> Text {
let head = el("h1", "", "Orders");
if self.rows == "" {
return head .. el("p", "", "No orders yet — " .. link("/", "", "go buy something") .. ".");
}
let thead = el("tr", "", el("th", "", "Product") .. el("th", "", "Qty") .. el("th", "", "Total") .. el("th", "", "Status"));
let table = el("table", "orders", thead .. self.rows);
return head .. table;
}
}