Common Lisp Package: IT.BESE.YACLML

Yet Another Common Lisp Markup Language

README:

FUNCTION

Public

EMIT-BODY (BODY)

Traverse body and emit the corresponding code. Every form in body is analyzed according to the following rules: cons whose car is not a known expander - code which should be included with no further analysis. cons whose car is a known expander - simply call the expander function with the cdr of the cons as the arg. yaclml-constant-p - print the constant (after escape-as-html) to *yaclml-stream*. cons whose car is YACLML-QUOTE - emit-body on every element of the cdr.

EMIT-CLOSE-TAG (NAME)

Emit the code required to print a close tag whose name is NAME.

EMIT-CODE (&REST FORMS)

Emit to the current yaclml-code CODE. This means that whatever CODE is it will be run, and it's result will be ignored, at runtime.

EMIT-EMPTY-TAG (NAME &REST ATTRIBUTES)

Emit the code required to print an empty tag with name NAME and a attributes ATTRIBUTES. See EMIT-OPEN-TAG for more details.

EMIT-HTML (&REST ITEMS)

Like EMIT-PRINC but escapes html chars in item.

EMIT-OPEN-TAG (NAME &REST ATTRIBUTES)

Emit the code required to print an open tag whose name is NAME and with the attributes ATTRIBUTES. ATTRIBUTES is expected to be an even long, setf-like list of name-value pairs defining the attributes.

EMIT-PRINC (&REST ITEMS)

Emit to the current yaclml-code a form which will, at runtime, princ ITEM. If (yaclml-constant-p ITEM) is true the princ will be done at compile time.

EMIT-PRINC-ATTRIBUTES (ATTRIBUTES)

Assuming attributes is a list of (name1 value1 name2 value2 ...), emit the code necessary to print them at runtime. If VALUE is a list every element will be concatenated separated by a space to form the final string value of the attribute. If the value of any of the attributes is NIL it will be ignored. If a value is the symbol T the name of the attribute will be used as the value.

EXTEND-ENVIRONMENT (NEW-ENVIRONMENT ENVIRONMENT)

Create a new environment with all the bindings in NEW-ENVIRONMENT and ENVIRONMENT. Any bindings in NEW-ENVIRNOMENT shadow (on successive calls to LOOKUP-TAL-VARIABLE) other bindings currently present in ENVIRONMENT.

MAKE-STANDARD-TAL-ENVIRONMENT (&REST BINDING-SETS)

Returns an environment consisting of BINDING-SETS. Each binding set can be an alist, an object, a hash table, or any object for which the a method on LOOKUP-TAL-VARIABLE has been defined. See alse: TAL-ENV

READ-TAL-EXPRESSION-FROM-STRING (EXPRESSION &OPTIONAL IMPLICIT-PROGN-P)

Reads a single form from the string EXPRESSION using the TAL expression read table.

TAL-ENV (&REST PAIRS)

Creates a fresh tal environment from the plist PAIRS.

TRANSFORM-LXML-FORM (FORM)

Transforms the lxml tree FORM into common lisp code (a series of calls to tag macros).

TRANSFORM-LXML-TREE (TREE)

Given a tree representing some LXML code with TAL attributes returns the yaclml tag using code for generating the HTML. Destructivly modifies TREE.

Undocumented

COMPILE-TAL-FILE (PATHNAME &OPTIONAL (EXPRESSION-PACKAGE (FIND-PACKAGE COMMON-LISP-USER)))

COMPILE-TAL-STRING (STRING &OPTIONAL (EXPRESSION-PACKAGE (FIND-PACKAGE COMMON-LISP-USER)))

ENABLE-YACLML-SYNTAX

HREF (BASE &REST PARAMS)

WITH-XML-SYNTAX

Private

$ tal reader (STREAM CHAR)

The $ char reader for tal expressions.

[ reader (STREAM CHAR)

Read a form using YACLML's [ syntax. Everything between the #[ and the #] is read as text. ~FORM prints (using <:as-html) the value returned by FORM while $FORM simply evaluates FORM and ignore the result.

COMPILE-TAL-STRING-TO-LAMBDA (STRING &OPTIONAL (EXPRESSION-PACKAGE *PACKAGE*))

Returns the source code for the tal function form the tal text STRING.

EMIT-FORM (FORM)

Emits the code to print FORM.

PARSE-ATTRIBUTE-SPEC (ATTRIBUTE-SPEC)

Parse an attribute spec into required args, attribute args, other args and the body arg.

PARSE-TAL-ATTRIBUTE-VALUE (VALUE-STRING)

Parser a TAL attribute expression, returns a form for building the expression at run time.

RALR-FORM (INSTANCE)

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

TAL-TEMPLATE.FILE-NAME (INSTANCE)

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

TAL-TEMPLATE.FUNCTION (INSTANCE)

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

TAL-TEMPLATE.LAST-LOAD-TIME (INSTANCE)

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

XML-READER-OPEN (S CHAR)

Emit XML elements into *yaclml-stream*, use keyword parameters for attributes and rest parameters for nested XML elements or normal lisp code. See enable-xml-syntax for more details.

YACLML-CONSTANT-P (THING)

Returns T if THING is, as far as yaclml is concerned, a run time constant.

Undocumented

%ENABLE-XML-SYNTAX

COPY-RUNTIME-ATTRIBUTE-LIST-REFERENCE (INSTANCE)

COPY-TAL-TEMPLATE (INSTANCE)

DISABLE-YACLML-SYNTAX

EMIT-ATTRIBUTE-VALUE (VALUE)

EMIT-INDENTATION

EMIT-PRINC-ATTRIBUTE (NAME VALUE)

MAKE-EFFECTIVE-ATTRIBUTES (ATTRIBUTES)

MAKE-RUNTIME-ATTRIBUTE-LIST-REFERENCE (&KEY ((FORM DUM0) NIL))

MAKE-TAL-TEMPLATE (&KEY ((LAST-LOAD-TIME DUM0) NIL) ((FILE-NAME DUM1) NIL) ((FUNCTION DUM2) NIL))

SETFRALR-FORM (NEW-VALUE INSTANCE)

READ-TAL-FILE-INTO-STRING (PATHNAME)

RUNTIME-ATTRIBUTE-LIST-REFERENCE-P (OBJECT)

TAL-TEMPLATE-P (OBJECT)

SETFTAL-TEMPLATE.FILE-NAME (NEW-VALUE INSTANCE)

SETFTAL-TEMPLATE.FUNCTION (NEW-VALUE INSTANCE)

SETFTAL-TEMPLATE.LAST-LOAD-TIME (NEW-VALUE INSTANCE)

MACRO

Public

DEF-ATTRIBUTE-HANDLER (ATTRIBUTE (TAG) &BODY BODY)

Defines a new attribute handler name ATTRIBUTE.

DEF-TAG-HANDLER (TAG-NAME (TAG) &BODY BODY)

Defines a new tag handlec named TAG-NAME.

DEFTAG (NAME ATTRIBUTES &BODY BODY)

Define a new tag. ATTRIBUTES should be an attribute-spec (see parse-attributes and attribute-bind). BODY is simply the body of the expander lambda. Within the BODY the functions EMIT-CODE, EMIT-PRINC and EMIT-HTML can be used to generate code. EMIT-CODE should be passed lisp code which will be executed at runtime.

DEFTAG-MACRO (NAME ATTRIBUTES &BODY BODY)

Define a new YACLML tag macro. Tag macros, like regular macros, expand into other YACLML tag forms which are recursivly processed.

ENABLE-XML-SYNTAX

Enable xml reader syntax for the file being compiled or loaded. You may consider using (enable-bracket-reader): {with-xml-syntax <foo :attr "bar" (lisp) >} Syntax examples: <foo :attribute "bar" (call lisp code) > <(progn 33) :bar 42 (@ "cAMeL" "eLitE-<>") "body-<>" > ==> <33 bar="42" cAMeL="eLitE-&lt;&gt;" >body-&lt;&gt;</33 > <"foo" :bar 42> ==> <foo bar="42"/>

TAL-VALUE (NAME)

Get the tal variable called NAME from -TAL-ENVIRONMENT-

WITH-YACLML-OUTPUT-TO-STRING (&BODY BODY)

Evaluate BODY with *yaclml-stream* bound to a string stream, return the string.

WITH-YACLML-STREAM (STREAM &BODY BODY)

Evaluate BODY with *yaclml-stream* bound to STREAM.

Undocumented

WRAP-IN-TAG ((TAG-NAME &REST TAG-ATTRIBUTES) &BODY BODY)

Private

ATTRIBUTE-BIND (ATTRIBUTE-SPEC ATTRIBUTE-VALUES &BODY BODY)

Evaluate BODY with the values in LIST bound according to ATTRIBUTE-SPEC. ATTRIBUTE-SPEC has the following form: ( required-args* [ &attribute attributes* ] [ &allow-other-attributes others ] [ &allow-custom-attributes customs ] [ &body body ] ) The symbols in REQUIRED-ARGS will be positionaly bound to the values in LIST. After the required args have been consumed any keyword value pairs will be consumed and bound to the corresponding attributes (binding form is just like &key in regular lambda lists, but only keyword symbols are allowed). If &allow-other-attributes is present then OTHERS will be bound to a list containing all the attributes in LIST which don't have a corresponding &attribute variable. &allow-other-attributes implies &allow-custom-attributes and OTHERS will contain also the custom attributes. If &allow-custom-attributes is present then CUSTOMS will be bound to a list containing all the custom attributes provided in (@ ...) sections. if &body is present then BODY will be bound to anything remaining in LIST after attribute parsing is complete.

DEF-EMPTY-HTML-TAG (NAME &REST ATTRIBUTES)

Define a tag that has `End Tag` set to Forbidden and `Empty` set to Empty according to: http://www.w3.org/TR/1999/REC-html401-19991224/index/elements.html used so generated XHTML would follow guidelines described in http://www.w3.org/TR/xhtml1/#guidelines

DEF-SIMPLE-XTAG (NAME)

Convience macro for defing tags which accept any kind of attribute and just wrap the body in an xml tag.

Undocumented

BIND-TAL-COMPILE-ENVIRONMENT (REQUESTED-VARS &BODY BODY)

BIND-TAL-COMPILE-ENVIRONMENT* (REQUESTED-VARS &BODY BODY)

DEF-HTML-TAG (NAME &REST ATTRIBUTES)

EMIT-ATTRIBUTE (NAME VALUE)

WITH-TAL-COMPILATION-UNIT (PATHNAME &BODY BODY)

WITH-TAL-COMPILE-ENVIRONMENT (REQUESTED-VARS &BODY BODY)

GENERIC-FUNCTION

Public

FETCH-TAL-VALUE (NAME BINDING)

Return the value associated with NAME in the binding set BINDING.

LOOKUP-TAL-VARIABLE (NAME ENVIRONMENT)

Return the value assciated with NAME (a symbol) in the environment ENVIRONMENT.

Undocumented

SETFFETCH-TAL-VALUE (VALUE NAME BINDING)

LOAD-TAL (GENERATOR NAME)

SETFLOOKUP-TAL-VARIABLE (VALUE NAME ENVIRONMENT)

TEMPLATE-TRUENAME (GENERATOR NAME)

Private

PREPROCESS-TAL (GENERATOR NAME)

Returns the source code which a certain TAL name will expand into. Used for debugging tal code.

Undocumented

ATTRIBUTE (CONDITION)

SETFATTRIBUTE (NEW-VALUE CONDITION)

ATTRIBUTE-TYPE (CONDITION)

SETFATTRIBUTE-TYPE (NEW-VALUE CONDITION)

SLOT-ACCESSOR

Public

Undocumented

ROOT-DIRECTORIES (OBJECT)

SETFROOT-DIRECTORIES (NEW-VALUE OBJECT)

Private

Undocumented

CACHEP (OBJECT)

SETFCACHEP (NEW-VALUE OBJECT)

VARIABLE

Public

*URI-TO-PACKAGE*

Default mapping of xmlns to packages.

*YACLML-INDENT*

When T (must be set while compiling yaclml code) the generated HTML is indented.

*YACLML-STREAM*

The stream to which tags are printed.

Undocumented

+XHTML-FRAMESET-DOCTYPE+

+XHTML-STRICT-DOCTYPE+

+XHTML-TRANSITIONAL-DOCTYPE+

Private

%YACLML-CODE%

The list of currently collected code this yaclml macro should expand into.

*EXPANDER-MACROS*

Hash table mapping expander macros to theri macre functions.

*EXPANDERS*

Hash table mapping expanders to the expander function.

*EXPRESSION-PACKAGE*

The value of *PACKAGE* when tal attribute expressions and for looking up symbols in the environment.

Undocumented

%YACLML-INDENTATION-DEPTH%

*HTML-PROLOGUE*

*READERS*

*TAL-ATTRIBUTE-HANDLERS*

*TAL-TAG-HANDLERS*

*TAL-TEMPLATES*

*XML-READER-CLOSE-CHAR*

*XML-READER-OPEN-CHAR*

CLASS

Public

Undocumented

FILE-SYSTEM-GENERATOR

TAL-GENERATOR

Private

Undocumented

RUNTIME-ATTRIBUTE-LIST-REFERENCE

TAL-TEMPLATE

CONDITION

Private

Undocumented

ILLEGAL-ATTRIBUTE-USE

SETF-TAL-VARIABLE-ERROR

UNFOUND-TAL-VARIABLE

UNRECOGNIZED-ATTRIBUTE

UNSETTABLE-TAL-VARIABLE