Wednesday, August 25, 2010

Creating tables in Racket webserver

I'm starting a journey into creating websites using DrRacket. Sometimes its documentation is a little opaque. If you're looking to create tables that look like this:
then you can do it using the following code:
#lang web-server/insta

(define (start request)
  `(html (head (title "Table test"))
         (body
         
          (h1 "Example 1")
          (p "The most basic of tables:")
          (table (tbody
                  (tr (td "one") (td "two"))
                  (tr (td "three") (td "four"))))
         
          (h1 "Example2")
          (p "Let's add some attributes: a table border, some cell spacing, and a width and background colour to one of the cells:")
          (table ((border "1") (cellspacing "10"))                 
                 (tbody
                  (tr (td ((width "100") (bgcolor "#FF6699")) "one") (td "two"))
                  (tr (td "three") (td "four"))))
            
         
          )))

No comments: