Advertisement
Guest User

opa stringmap iteration issues

a guest
Apr 4th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. type item = {string description, string url}
  2.  
  3. database mydb {
  4. stringmap(item) /items
  5. }
  6.  
  7. /mydb/items["google"] = {description: "search the interwebs with google!", url: "http://google.com"}
  8. /mydb/items["yahoo"] = {description: "search the interwebs with yahoo!", url: "http://yahoo.com"}
  9.  
  10. function render_item(item) {
  11. <>
  12. <li>
  13. <h4>item</h4>
  14. <a href="/mydb/items[item]/url">{/mydb/items[item]/description}</a>
  15. </li>
  16. </>
  17. }
  18.  
  19. function render_index() {
  20. <>
  21. <ul>
  22. {StringMap.iter(function(item) {render_item(item)}, /mydb/items)}
  23. </ul>
  24. </>
  25. }
  26.  
  27. Server.start(Server.http, {title: "test", page: render_index})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement