HTML templating in Scheme?

Templating is one of those must-haves for building websites; separating content from presentation is sliced bread compared to cavalierly interleave logic and HTML into one file. In Scheme, I think that quasiquotation could be used in wonderful ways to create templates; namely, every template can be a function that simply takes parameters and directly uses quasiquotation as the templater:

(define blog-post-template
  (lambda (title date message comments)
       (head (title "My Blog - " ,title))
         (div (@ (class "post"))
           (h1 ,title)
         (div (@ (class "comments"))
           (p ,comments) ...)))))

and then to use it, you would just use

  "Another pedantic blog post"
  "Nov 20, 2010"
  "Today I'm going to complain about everything ..."
  '("Awesome blog!"
    "Actually, I disagree with you on everything"

You could also add a little more flexibility into your template by accepting an association list of parameters rather than fixed parameters:

(define blog-post-template
  (lambda params
       (head (title "My Blog - " ,(cadr (assq 'title params))))

which can be made easier to use by redefining quasiquote with some templating-specific conveniences.

Petite Chez Scheme for Ubuntu

An Ubuntu package of Petite Chez Scheme seems to be a common request among students, given the popularity of Ubuntu among the techno-capable. ¬†Currently, only RPM packages are provided on the Chez Scheme site, and the traditional recommendation was to use alien to convert the RPM into a .deb. There’s no reason to have everybody do this though.

I’ve built a .deb package of Petite Chez Scheme for amd64 (64-bit) Ubuntu 10.10. You should be able to install it by simply double-clicking the package and following the on-screen prompts. Petite can then be run using the terminal command `petite`.

Known issues: No package docs.