HTML-TEMPLATE add-ons

HTML-TEMPLATE is a portable library for Common Lisp written by Edi Weitz. It is used to fill templates with arbitrary values at runtime. (Actually, it does not matter whether the result is HTML but this the library is mostly used for it.) It is loosely modeled after the Perl module HTML::Template and partially compatible with a its syntax, though both libraries contain some extensions that the other does not support.

The detail information about HTML-TEMPLATE, source code, and documentation can be downloaded from http://weitz.de/html-template/.

The only purpose of this page is to contribute the above repository by the small add-on.

"Lispy" extension of TMPL_tag syntax

  1. A Lisp form in place of "plane attribute" is allowed. Forms are read by the standard read function. All starting tags except TMPL_INCLUDE accept forms instead of "old style" attributes.
    To force reading those tags in "compatibility" mode, set *attributes-are-lisp-forms*, a new special variable, to NIL.
  2. Symbols follow standard Lisp syntax: a package specifier is allowed in front of the name. By default, symbols are interned into the package stored in *template-package*, a new special variable.
  3. To interpret the forms in run-time, the template-eval was introduced. It is a simple evaluator akin to the standard eval function except for:
  4. The TMPL_EVAL tag and create-eval-printer were introduced; the former should be used instead of the TMPL_VAR tag.

  5. html-template-0.10.1.zip
    48kB
  6. The value of *format-non-strings* has got an additional meaning. If it equals to T, the result is produced by means of princ-to-string, i.e. (format nil "~A" ...).
    If it is true but not equals to T, the value must be a single-parameter function, which returns two values:
    (1) a string resulted from its argument, and optionally
    (2) do-not-modify flag controlling whether *string-modifier* is applied afterwads.
    The truth as second value can prevent the result of converting from predefined format, e.g. LHTML, from further escaping.
  7. Tag TMPL_ELSE and all ending tags /TMPL_... can contain an optional text between the tag name and the closing marker "-->". This text is intended for readability only and completely ignored by the template parser. For example: <!-- /TMPL_LOOP rows -->

The source code of this addition is not available as a patch at the moment. All the new and altered definitions are in template-eval.lisp, which is included into the html-template-0.10.1.zip bundle. This separate file could be compiled and loaded after the html-template system.

Πειςθνγ@Mail.ru
Rambler's Top100