1 Introduction

HTML-TEMPLATE - Use HTML templates from Common Lisp

HTML-TEMPLATE is a portable library for Common Lisp which can be used
to fill templates with arbitrary (string) values at runtime.
(Actually, it doesn't matter whether the result is HTML. It's just
very likely that this will be what the library is mostly used for.)

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.

HTML-TEMPLATE translates templates into efficient closures which can
be re-used as often as needed. It uses an intelligent cache mechanism
so you can nevertheless update templates while your program is running
and have the changes take effect immediately.

5.1.3 Generic functions

Creates a template printer from TEMPLATE which is
an open input stream, a string, or a pathname. If FORCE is true a
printer will be newly created no matter what the state of the cache
is. If FORCE is :DO-NOT-CACHE the newly created printer won’t be
cached. Other keyword arguments will be given to WITH-OPEN-FILE.
Keyword arguments will only be accepted if TEMPLATE is a PATHNAME.

Fills the template denoted by TEMPLATE/PRINTER with
VALUES and print it to STREAM. If TEMPLATE/PRINTER is a function uses
it as if it were a template printer, otherwise creates a printer (or
pull one out of the cache) with CREATE-TEMPLATE-PRINTER. Optional
keyword arguments are given to CREATE-TEMPLATE printer and can only be
used if TEMPLATE/PRINTER is a pathname.

Used internally to create template printers for TMPL_CALL tags.
SYMBOL is the symbol associated with the tag. BODY-FN is the template
printer for the body of the loop. NEXT-FN is the next function to be
called in the chain of closures. STRING-LIST is a list of strings in
reverse order to be printed first.

Used internally to create template printers for TMPL_IF and
TMPL_UNLESS tags. SYMBOL is the symbol associated with the tag. IF-FN
is the printer for the IF branch, ELSE-FN is the printer for the ELSE
branch. NEXT-FN is the next function to be called in the chain of
closures. STRING-LIST is a list of strings in reverse order to be
printed first. If UNLESSP is true, IF-FN and ELSE-FN are switched.

Used internally to create template printers for TMPL_INCLUDE.
PATHNAME is the pathname associated with the tag. NEXT-FN is the next
function to be called in the chain of closures. STRING-LIST is a list
of strings in reverse order to be printed first.

Used internally to create template printers for TMPL_LOOP
tags. SYMBOL is the symbol associated with the tag. BODY-FN is the
template printer for the body of the loop. NEXT-FN is the next
function to be called in the chain of closures. STRING-LIST is a list
of strings in reverse order to be printed first.

Used internally to create template printers for TMPL_REPEAT
tags. SYMBOL is the symbol associated with the tag. BODY-FN is the
template printer for the body of the loop. NEXT-FN is the next
function to be called in the chain of closures. STRING-LIST is a list
of strings in reverse order to be printed first.

Used internally to create template printers for strings which don’t
include template tags. NEXT-FN is the next function to be called in
the chain of closures. STRING-LIST is a list of strings in reverse
order to be printed first.

Reads from *STANDARD-INPUT* and returns a template printer from
what it reads. When this function is entered the stream pointer must
not be inside a template tag. STRING-STACK is a list of strings (in
reverse order) read so far which haven’t been used to build a template
printer. END-TOKEN is either NIL or one of :LOOP, :REPEAT, :IF,
:IF-ELSE, or :UNLESS-ELSE denoting that we expect certain tags to
close open TMPL_LOOP, TMPL_REPEAT, TMPL_IF, or TMPL_UNLESS tags. This
function returns a second value which is true if, after reading
TMPL_IF or TMPL_UNLESS, a corresponding TMPL_ELSE was seen.

Used internally to create template printers for TMPL_VAR. SYMBOL is
the symbol associated with the tag. NEXT-FN is the next function to be
called in the chain of closures. STRING-LIST is a list of strings in
reverse order to be printed first.

Reads and returns a string from *STANDARD-INPUT*. The string is
either delimited by ’ or " in which case the delimiters aren’t
returned or it is assumed to extend to the next whitespace
character. See READ-WHILE’s docstring for EOF-ACTION.

Reads the rest of a template tag from *STANDARD-INPUT* after the
name of the tag has been read. Reads and returns the tag’s attribute
if READ-ATTRIBUTE is true. Optionally also interns the attribute
string if INTERN is true. See READ-WHILE’s docstring for EOF-ACTION.

Reads characters from *STANDARD-INPUT* while PREDICATE returns a
true value for each character. Returns the string which was read
unless SKIP is true. On reading EOF an error is signaled if
EOF-ACTION is T, NIL is silently returned if EOF-ACTION is NIL, or the
function EOF-ACTION is called with one argument - the string read so
far.

Reads and skips whitespace from *STANDARD-INPUT* until a #Newline
characters is seen if *IGNORE-EMPTY-LINES* is true. If there is no
#Newline before the first non-whitespace character the string read so
far is returned (wrapped in a list).

Read characters from *STANDARD-INPUT* as long as they are
whitespace. Signals an error if the first character read isn’t
whitespace and ASSERT is true. Return the string which was read unless
SKIP is true. See READ-WHILE’s docstring for EOF-ACTION.