Joe, I will definitely try your solution.
On Thursday, December 22, 2011 8:41:52 PM UTC+1, gwanwyn wrote:
> Hello everybody,
> I have a question, I want to fill rows in html table from a struct-map. I
> have a problem with row snippet, because I don't know how to define cell
> selectors. Each key value pair from my struct map is for one cell in a row.
> So my question is how do I define cell selectors, do I have to go one by
> one cell, or is there any other way to do it (there probably is one but I
> just can't seem to find it). I would probably need some kind of dynamic
> selector...
> Here is my row html from the file index.html
> <tr>
> <td>Event Title</td>
> <td>Type of event</td>
> <td>Performer</td>
> <td>About</td>
> <td>Date</td>
> <td>Start time</td>
> <td>End time</td>
> <td>Place</td>
> <td>Video</td> </tr> Here are my selectors,
> snippets and template (def *first-cell-sel* [[:tr (html/nth-child 1)][:td
> html/first-child]]) (def *rest-cell-sel* [[:table] [:tr (html/nth-child
> 2)][:td (html/nth-child 2)]]) (defsnippet second-cell
> "eventsmashup/index.html" [[:table] [:tr (html/nth-child 1)][:td
> (html/nth-child 2)]] [{value :performer}] [:td] (html/content value))
> (defsnippet cell-model "eventsmashup/index.html" *first-cell-sel* [{value
> :value}] [:td] (html/content value)) (defsnippet row-model
> "eventsmashup/index.html" *row-sel* [{:keys [event-data]} model] [:tr]
> (html/content (map model event-data))) (deftemplate index
> "eventsmashup/index.html" [{:keys [event-data]}] [:tbody] (html/content
> (map #(row-model % cell-model % second-cell)rows))) and here is part of
> dummy-content struct-map, that I use for testing (def *dummy-content*
> {:title "Events Mashup" :rows [ { :event-data [{:event-name "event name 1"
> :performer "performer 1" :date "date 1" :start-time "start time 1"
> :end-time "start time 1"}]}]}) When I start the app, the table is blank, my
> code doesn't insert any content, and I can't seem to get the reason why. If
> anybody can give me the answer I'd be really grateful. Thanks Vesna
On Thursday, December 22, 2011 8:41:52 PM UTC+1, gwanwyn wrote:
> Hello everybody,
> I have a question, I want to fill rows in html table from a struct-map. I
> have a problem with row snippet, because I don't know how to define cell
> selectors. Each key value pair from my struct map is for one cell in a row.
> So my question is how do I define cell selectors, do I have to go one by
> one cell, or is there any other way to do it (there probably is one but I
> just can't seem to find it). I would probably need some kind of dynamic
> selector...
> Here is my row html from the file index.html
> <tr>
> <td>Event Title</td>
> <td>Type of event</td>
> <td>Performer</td>
> <td>About</td>
> <td>Date</td>
> <td>Start time</td>
> <td>End time</td>
> <td>Place</td>
> <td>Video</td> </tr> Here are my selectors,
> snippets and template (def *first-cell-sel* [[:tr (html/nth-child 1)][:td
> html/first-child]]) (def *rest-cell-sel* [[:table] [:tr (html/nth-child
> 2)][:td (html/nth-child 2)]]) (defsnippet second-cell
> "eventsmashup/index.html" [[:table] [:tr (html/nth-child 1)][:td
> (html/nth-child 2)]] [{value :performer}] [:td] (html/content value))
> (defsnippet cell-model "eventsmashup/index.html" *first-cell-sel* [{value
> :value}] [:td] (html/content value)) (defsnippet row-model
> "eventsmashup/index.html" *row-sel* [{:keys [event-data]} model] [:tr]
> (html/content (map model event-data))) (deftemplate index
> "eventsmashup/index.html" [{:keys [event-data]}] [:tbody] (html/content
> (map #(row-model % cell-model % second-cell)rows))) and here is part of
> dummy-content struct-map, that I use for testing (def *dummy-content*
> {:title "Events Mashup" :rows [ { :event-data [{:event-name "event name 1"
> :performer "performer 1" :date "date 1" :start-time "start time 1"
> :end-time "start time 1"}]}]}) When I start the app, the table is blank, my
> code doesn't insert any content, and I can't seem to get the reason why. If
> anybody can give me the answer I'd be really grateful. Thanks Vesna