As an aside, useful HTML templates don't have to be in HTML syntax; Racket programmers can do this:

#lang racket/base

(require (planet neil/html-template:1:0))

(define (write-fastest-in-the-west-page-html thing)
  (html-template
   (html (head (title "Fastest " (% thing) " in the West!")
               (body (h1 "Bang!")
                     (h2 "Bang & Olufson!"))))))

(write-fastest-in-the-west-page-html "Strunk & White")


Which outputs this:


<html><head><title>Fastest Strunk &amp; White in the West!</title><body><h1>Bang!</h1><h2>Bang &amp; Olufson!</h2></body></head></html>


Note the escaping by default of both the static (from the procedure's perspective) "&", in "Bang & Olufson", and the dynamic one, in "Strunk & White".

For possible improved performance, syntax transformation of that procedure expands it to the following, during compilation:


(define (write-fastest-in-the-west-page-html thing)
  (begin
    (display "<html><head><title>Fastest ")
    (write-html thing)
(display " in the West!</title><body><h1>Bang!</h1><h2>Bang &amp; Olufson!</h2></body></head></html>")
    (void)))


--
http://www.neilvandyke.org/
_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/users

Reply via email to