- separate view.html files dropped; every render() now carries its
'-- 37 target:' literal above the hand-lowered body — the pair is
the DX referendum in one file
- story 37 re-pointed: raw multi-line literal + {{ }} auto-escaped
typed holes + {!! !!} raw slots; structural control stays if/for;
w:if/w:for and .html files demoted to later; forks revised
- rebuild verified on untouched toolchain
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
72 lines
2.2 KiB
Text
72 lines
2.2 KiB
Text
-- orders/view.wo — the confirmation page and the orders table. The
|
||
-- comment above each render() is the STORY-37 TARGET (raw template
|
||
-- literal, {{ }} auto-escaped); the body is today's hand-lowering.
|
||
use html
|
||
|
||
pub class OrderOk {
|
||
name: Text
|
||
qty: Int
|
||
total: Float
|
||
|
||
-- 37 target:
|
||
-- return `
|
||
-- <div class="card">
|
||
-- <h1>Order placed</h1>
|
||
-- <p>{{ self.qty }} × {{ self.name }} — total € {{ self.total }}</p>
|
||
-- <p><a href="/orders">See all orders</a> · <a href="/">Keep shopping</a></p>
|
||
-- </div>`;
|
||
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
|
||
|
||
-- 37 target:
|
||
-- return `
|
||
-- <tr>
|
||
-- <td>{{ self.name }}</td>
|
||
-- <td>{{ self.qty }}</td>
|
||
-- <td>€ {{ self.total }}</td>
|
||
-- <td>{{ self.status }}</td>
|
||
-- </tr>`;
|
||
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
|
||
|
||
-- 37 target:
|
||
-- if self.rows == "" {
|
||
-- return `<h1>Orders</h1>
|
||
-- <p>No orders yet — <a href="/">go buy something</a>.</p>`;
|
||
-- }
|
||
-- return `
|
||
-- <h1>Orders</h1>
|
||
-- <table class="orders">
|
||
-- <tr><th>Product</th><th>Qty</th><th>Total</th><th>Status</th></tr>
|
||
-- {!! self.rows !!}
|
||
-- </table>`;
|
||
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;
|
||
}
|
||
}
|