On Thu, 17 Nov 2011 07:47:32 -0800, Jim Barrows <jim.barrows@gmail.com> wrote:

I'm pulling records from a database, and I don't know how many I'll have.  I need to display them in a 3 by X grid built in CSS.  So it needs to look something like:
(:div :class "row" 
  (:div :class "span-one-third" "1/3")
  (:div :class "span-one-third" "1/3")
  (:div :class "span-one-third" "1/3"))

Since I don't know how many rows are returning, I can't really hard code it like the above example.

I'm new to lisp, so I may just be thinking about this in the wrong way.  In Java, opening a tag like this and closing it is a very common pattern.  Maybe I'm just thinking too much in Java...
--
James A Barrows

Here's one way:

(let ((records '((1 2 3) (4 5 6) (7 8 9))))
   (with-html-output (*standard-output* nil :indent 0)
     (dolist (rec records)
       (htm (:div :class "row"
         (dolist (col rec)
           (htm (:div :class "span-one-third" (str col)))))))))

Jeff Cunningham