
opa stringmap iteration issues
By: a guest on
Apr 4th, 2012 | syntax:
None | size: 0.62 KB | hits: 10 | expires: Never
type item = {string description, string url}
database mydb {
stringmap(item) /items
}
/mydb/items["google"] = {description: "search the interwebs with google!", url: "http://google.com"}
/mydb/items["yahoo"] = {description: "search the interwebs with yahoo!", url: "http://yahoo.com"}
function render_item(item) {
<>
<li>
<h4>item</h4>
<a href="/mydb/items[item]/url">{/mydb/items[item]/description}</a>
</li>
</>
}
function render_index() {
<>
<ul>
{StringMap.iter(function(item) {render_item(item)}, /mydb/items)}
</ul>
</>
}
Server.start(Server.http, {title: "test", page: render_index})