Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think you've got a few minor problems with your code. I've made an attempt at correcting them in the code below. Testing this with Compojure 0.3.2, I dare say that it works. (Feel free to point out anything that requires improvement or seems not to work for you, of course.)</p> <pre><code>(use 'compojure) ; you'd use a ns form normally ;;; I'm not using a ref here; this doesn't change much, ;;; though with a ref / atom / whatever you'd have to take care ;;; to dereference it once per request so as to generate a consistent ;;; (though possibly outdated, of course) view of data; ;;; this doesn't come into play here anyway (def smpl2 {"Salaried" [{"John Doe" ["12:00-20:00" nil nil nil "11:00-19:00"]} {"Mary Jane" [nil "12:00-20:00" nil nil nil "11:00-19:00"]}] "Shift Manager" [{"Peter Simpson" ["12:00-20:00" nil nil nil "11:00-19:00"]} {"Joe Jones" [nil "12:00-20:00" nil nil nil "11:00-19:00"]}] "Other" [{"Super Man" ["07:00-16:00" "07:00-16:00" "07:00-16:00" "07:00-16:00" "07:00-16:00"]}]}) (defn html-doc [title &amp; body] (html (doctype :xhtml-transitional) ; the idiomatic way to insert ; the xtml/transitional doctype [:html [:head [:title title]] [:body body]])) (defn create-table [] (html [:h1 "Schedule"] [:hr] [:table {:style "border: 0; width: 90%;"} [:tr [:th "Name"][:th "Mon"][:th "Tue"][:th "Wed"] [:th "Thur"][:th "Fri"][:th "Sat"][:th "Sun"]] (for [category smpl2] [:div [:tr [:td (key category)]] ; for returns just one thing per ; 'iteration', so I'm using a div ; to package two things together; ; it could be avoided, so tell me ; if it's a problem (for [people (val category)] (for [person people] [:tr [:td (key person)] (for [hours (val person)] [:td hours])]))])])) (defn index-html [request] (html-doc "Sample" (create-table))) (defroutes test-routes (GET "/" index-html) (ANY "*" 404)) (defserver test-server {:port 8080} "/*" (servlet test-routes)) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload