Common Lisp Package: HTML-TEMPLATE

README:

FUNCTION

Public

CLEAR-TEMPLATE-CACHE

Complete clears all template printers from the cache.

DELETE-FROM-TEMPLATE-CACHE (PATHNAME)

Deletes the template printer denoted by PATHNAME from the cache. Returns true if such a printer existed, false otherwise.

ESCAPE-STRING (STRING &KEY (TEST *ESCAPE-CHAR-P*))

Escape all characters in STRING which pass TEST. This function is not guaranteed to return a fresh string. Note that you can pass NIL for STRING which'll just be returned.

ESCAPE-STRING-ALL (STRING)

Escapes all characters in STRING which aren't in the 7-bit ASCII character set.

ESCAPE-STRING-ISO-8859-1 (STRING)

Escapes all characters in STRING which aren't defined in ISO-8859-1.

ESCAPE-STRING-MINIMAL (STRING)

Escape only #<, #>, and #& in STRING.

ESCAPE-STRING-MINIMAL-PLUS-QUOTES (STRING)

Like ESCAPE-STRING-MINIMAL but also escapes quotes.

Private

%CREATE-TEMPLATE-PRINTER-AUX (&REST ARGS)

Wrapper for CREATE-TEMPLATE-PRINTER-AUX to initialize *CURRENT-COLUMN* and *CURRENT-LINE*.

%READ-CHAR

Like READ-CHAR but updates the line and column counters.

CREATE-CALL-PRINTER (STRING-LIST SYMBOL NEXT-FN)

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.

CREATE-IF-PRINTER (STRING-LIST SYMBOL IF-FN ELSE-FN NEXT-FN UNLESSP)

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.

CREATE-INCLUDE-PRINTER (STRING-LIST PATHNAME NEXT-FN)

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.

CREATE-LOOP-PRINTER (STRING-LIST SYMBOL BODY-FN NEXT-FN)

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.

CREATE-REPEAT-PRINTER (STRING-LIST SYMBOL BODY-FN NEXT-FN)

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.

CREATE-SIMPLE-PRINTER (STRING-LIST &OPTIONAL (NEXT-FN #'NO-VALUES))

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.

CREATE-TEMPLATE-PRINTER-AUX (STRING-STACK END-TOKEN)

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.

CREATE-VAR-PRINTER (STRING-LIST SYMBOL NEXT-FN)

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.

LIST-TO-STRING (STRING-LIST)

Concatenates a list of strings to one string in reverse order. The list is destructively modified.

NO-VALUES (&REST REST)

A function which does not return any values. This is always the last function in a chain of template printer closures.

READ-DELIMITED-STRING (&KEY (EOF-ACTION T))

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.

READ-TAG-REST (&KEY READ-ATTRIBUTE (INTERN T) (EOF-ACTION T))

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.

READ-UNTIL (STRING &KEY (SKIP T) (EOF-ACTION T))

Reads characters from *STANDARD-INPUT* up to and including STRING. Return the string which was read (excluding STRING) unless SKIP is true. See READ-WHILE's docstring for EOF-ACTION.

READ-WHILE (PREDICATE &KEY (SKIP T) (EOF-ACTION T))

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.

SKIP-LEADING-WHITESPACE (STRING)

Removes whitespace from the end of STRING up to and including a #Newline. If there is no #Newline before the first non-whitespace character is seen nothing is removed. STRING must have a fill pointer.

SKIP-TRAILING-WHITESPACE

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).

SKIP-WHITESPACE (&KEY ASSERT (SKIP T) (EOF-ACTION T))

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.

SYNTAX-ERROR-LOCATION-COL (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SYNTAX-ERROR-LOCATION-LINE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SYNTAX-ERROR-LOCATION-STREAM (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

COPY-SYNTAX-ERROR-LOCATION (INSTANCE)

HYPERDOC-LOOKUP (SYMBOL TYPE)

MAKE-SYNTAX-ERROR-LOCATION (&KEY ((LINE DUM0) NIL) ((COL DUM1) NIL) ((STREAM DUM2) NIL))

SETFSYNTAX-ERROR-LOCATION-COL (NEW-VALUE INSTANCE)

SETFSYNTAX-ERROR-LOCATION-LINE (NEW-VALUE INSTANCE)

SYNTAX-ERROR-LOCATION-P (OBJECT)

SETFSYNTAX-ERROR-LOCATION-STREAM (NEW-VALUE INSTANCE)

MACRO

Private

WHITESPACEP (CHAR)

Checks whether CHAR is whitespace.

WITH-SYNTAX-ERROR-LOCATION ((&REST REST) &BODY BODY)

This is wrapped around forms in order to remember a meaningful position within the stream in case an error has to be signaled.

WITH-USE-VALUE-RESTART ((SYMBOL) ERROR-FORM)

Provide a USE-VALUE restart for ERROR-FORM in case the value associated with SYMBOL isn't to our liking.

Undocumented

SIGNAL-TEMPLATE-INVOCATION-ERROR (FORMAT-CONTROL &REST FORMAT-ARGUMENTS)

SIGNAL-TEMPLATE-MISSING-VALUE-ERROR (FORMAT-CONTROL &REST FORMAT-ARGUMENTS)

SIGNAL-TEMPLATE-SYNTAX-ERROR (FORMAT-CONTROL &REST FORMAT-ARGUMENTS)

GENERIC-FUNCTION

Public

CREATE-TEMPLATE-PRINTER (TEMPLATE &KEY FORCE ELEMENT-TYPE IF-DOES-NOT-EXIST EXTERNAL-FORMAT (FORCE *FORCE-DEFAULT*) (ELEMENT-TYPE 'CHARACTER) (IF-DOES-NOT-EXIST ERROR) (EXTERNAL-FORMAT *EXTERNAL-FORMAT*))

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.

FILL-AND-PRINT-TEMPLATE (TEMPLATE/PRINTER VALUES &KEY STREAM (STREAM *DEFAULT-TEMPLATE-OUTPUT*) &ALLOW-OTHER-KEYS)

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.

Undocumented

TEMPLATE-NOT-A-STRING-ERROR-VALUE (CONDITION)

TEMPLATE-SYNTAX-ERROR-COL (CONDITION)

TEMPLATE-SYNTAX-ERROR-LINE (CONDITION)

TEMPLATE-SYNTAX-ERROR-STREAM (CONDITION)

VARIABLE

Public

*CALL-TEMPLATE-ACCESS-FUNCTION*

Accessor function for extracting the called template from a TMPL_CALL form.

*CONVERT-NIL-TO-EMPTY-STRING*

Controls whether NIL values should resolve to empty strings or raise an error.

*DEFAULT-TEMPLATE-OUTPUT*

The output stream used by FILL-AND-PRINT-TEMPLATE when no STREAM keyword was provided.

*DEFAULT-TEMPLATE-PATHNAME*

Each pathname is merged with this value before it is used by CREATE-TEMPLATE-PRINTER.

*ESCAPE-CHAR-P*

Used by ESCAPE-STRING to test whether a character should be escaped.

*FORCE-DEFAULT*

The default value for the FORCE keyword argument to CREATE-TEMPLATE-PRINTER.

*FORMAT-NON-STRINGS*

Controls whether TMPL_VAR will accept values which aren't strings and convert them using (FORMAT NIL "~A" ...).

*IGNORE-EMPTY-LINES*

Controls whether template tags on their own lines produce empty lines or not.

*NO-CACHE-CHECK*

Controls whether the FILE-WRITE-DATE check will be circumvented when using FILL-AND-PRINT-TEMPLATE.

*SEQUENCES-ARE-LISTS*

Controls whether TMPL_LOOP printers expect lists or vectors.

*STRING-MODIFIER*

The function which is applied to strings which replace TMPL_VAR tags. Use #'CL:IDENTITY if you don't want to change the strings.

*TEMPLATE-END-MARKER*

The string template tags must end with

*TEMPLATE-START-MARKER*

The string template tags must start with

*TEMPLATE-SYMBOL-PACKAGE*

The package symbols are interned into.

*UPCASE-ATTRIBUTE-STRINGS*

Controls whether attribute strings associated with template tags are upcased before they are interned.

*VALUE-ACCESS-FUNCTION*

The function which associates (attribute) symbols with their values.

*WARN-ON-CREATION*

Controls whether a warning should be signaled if a new template printer is created from a pathname argument.

Private

*CALL-VALUE-ACCESS-FUNCTION*

Accessor function for extracting the values from a TMPL_CALL form.

*CURRENT-COLUMN*

Internal column counter of the parser.

*CURRENT-LINE*

Internal line counter of the parser.

*EXTERNAL-FORMAT*

The external format used when opening files.

*FIND-STRING-HASH*

Hash tables used internally by READ-UNTIL to cache offset arrays.

*INCLUDED-FILES*

Internally used by CREATE-TEMPLATE-PRINTER-AUX to avoid infinite TMPL_INCLUDE loops.

*PRINTER-HASH*

The cache for template printers. Each entry is of the form (PRINTER . WRITE-DATE).

*SYNTAX-ERROR-LOCATION*

Used internally to remember the last position which made sense to the parser.

*TEMPLATE-OUTPUT*

The output stream that's used internally.

Undocumented

*HYPERDOC-BASE-URI*

CLASS

Private

SYNTAX-ERROR-LOCATION

Structure to store parser locations consisting of a stream, a line number, and a column number.

CONDITION

Public

TEMPLATE-ERROR

All errors signaled by HTML-TEMPLATE are of this type.

TEMPLATE-INVOCATION-ERROR

Signaled when HTML-TEMPLATE functions are invoked with wrong arguments.

TEMPLATE-MISSING-VALUE-ERROR

Signaled when a TMPL_VAR printer is provided with a NIL value and *CONVERT-NIL-TO-EMPTY-STRING* is false.

TEMPLATE-NOT-A-STRING-ERROR

Signaled when a TMPL_VAR printer is provided with a non-string value.

TEMPLATE-SYNTAX-ERROR

Signaled when a syntax error occurs while parsing a template.