Yaclml

YACLML - Programmatic HTML Generation 

The programmatic interface is a collection of Common Lisp macros designed to make embedding HTML in lisp code easy. It was created with the following goals in mind:

- The code for creating HTML should look and act like regular lisp code.

- Given what we know about HTML and the ratio of static to dynamic text in a typical web page it's important to constant fold as much as possible.

- Tags should be easily definable and should be able to perform arbitrary computations at both run time and compile time.

Using YACLML Tag Macros 

You use YACLML tags just like regular macros, any attributes are passed in like keyword arguments. YACLML examines its args (at compile time) and distinguishes between the keyword arguments which become attributes and everything else, which becomes the tag's body. Tags all have the following syntax:

( tag-name [ :keyword value ] * . body )

Tag Attributes 

The name of the attribute will be the result of string-downcase'ing the symbol-name specified in the macro. Depending on the runtime value returned executing the value specified in the macro call three things can happen:

NIL - The attribute will be ignored

T - The attribute will be printed with (string-downcase name) as the value.

anything else - The result of evaluating the value will be printed (via PRINC) as the value of the attribute.

If the need ever arises to have an HTML attribute whose value is T or NIL it is necessary to return the string \"T\" or \"NIL\" and not the symbol T or NIL.

The Tag Body 

Every element of the tag body is processed in order: if it is a form it is executed at runtime and must explicitly print to the stream *yaclml-stream* if it needs to generate output, if it is a string its value will be printed to *yaclml-stream* at run time.

Examples 

;; Assuming *yaclml-stream* is bound to *standard-output*

(<:a :href \"http://foo.com\" \"foo.com\") => <a href=\"http://foo.com\">foo.com</a>

(<:br) => <br/>

(<:td \"whatever\") => <td>whatever</td>