Skip to content

Instantly share code, notes, and snippets.

@themattchan
Last active November 15, 2015 04:29
Show Gist options
  • Save themattchan/1a0578a12e96217536d1 to your computer and use it in GitHub Desktop.
Save themattchan/1a0578a12e96217536d1 to your computer and use it in GitHub Desktop.
fuck xml.
#lang racket
(require xml)
(require xml/xexpr)
(define to-html (compose display
xexpr->string))
(define CONFIGS '((siteName "Andromeda")
(latitude 1234.567)
(widescreen #t)))
(define (display-cell cell) `(td ,(~a cell)))
(define (display-row row) `(tr ,@(map display-cell row)))
(define (display-table title rows) `(table ((style "width:100%"))
(caption ,title)
,@(map display-row rows)))
(to-html (display-table "Configs" CONFIGS))
#| ==>
<table style="width:100%"><caption>Configs</caption><tr><td>siteName</td><td>Andromeda</td></tr><tr><td>latitude</td><td>1234.567</td></tr><tr><td>widescreen</td><td>#t</td></tr></table>
|#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment