Hacker News new | past | comments | ask | show | jobs | submit login

The macro is documented here: http://weitz.de/cl-who/#syntax

In particular, each list beginning with a keyword is transformed into an (X)HTML tag. It is an easy way to handle all current and future HTML elements without defining a function for each element and their attributes. You might be thinking: "we could generate invalid HTML", and yes, it is true. Other libraries exist to generate HTML, but this one is quite popular.

The other interesting thing is that by processing the tree at compile time, you can make some optimizations. For example, the following form:

    (:html (:body (:h1 "Hi")))
... is expanded as:

    (WRITE-STRING "<html><body><h1>Hi</h1></body></html>" *STANDARD-OUTPUT*)
... because it does not depend on external data. However, if instead of a constant string, you place (str (something)), you have instead:

    (WRITE-STRING "<html><body><h1>" *STANDARD-OUTPUT*)
      (LET ((CL-WHO::*INDENT* NIL))
        NIL
        (STR (SOMETHING)))
    (WRITE-STRING "</h1></body></html>" *STANDARD-OUTPUT*)))



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: