// Part of the inventory program (see main.nika): the HTML page.
use std::html
// `title` is an option: it stands after the `;`, has a default, and a call
// that wants another one names it: `render(entries, total; title: "Tools")`.
pub fn render(entries: Vec[Entry], total: int; title: String = "Stock") -> String {
return dsl html {
<html>
<head><title>{title}</title></head>
<body>
<h1>{title}</h1>
<table>
<tr><th>Category</th><th>Item</th><th>Count</th></tr>
<for e in :entries><tr><td>{e.category}</td><td>{e.item}</td><td>{e.count}</td></tr></for>
</table>
<p>{total} in total</p>
</body>
</html>
} eod
}
The file itself · all the examples