Zope Template Language
Design Aims
Simplicity. It should really be as simple and self revealing as possible. Like python ;-)
Flexiblity. It should designed to be flexible and future proof ( enough ;-) so that nasty hacks
aren't needed to introduce new languages, etc
It should provide language functionality, not library functionality. I'm thinking of the sendmail
and calendar tags here ;-)
It should be aimed at templating. That is: taking a lump of text and inserting bits of computed stuff in it or repeating bits of stuff.
This is significantly different from what languages like Python and Perl are designed for.
Being XML parsable seems to be a Good Thing (tm) aside from providing some nifty syntax...
Tag Structure
<z:tag_name attributevalues />
or
<z:tag_name attributevalues >
tagcontent
<z:tag_name>
where:
attributevalues -> attributevalue *attributevalues* | attributevalue
attributevalue -> attribute-type="value"
- tag_name
The name of the tag.
- tagcontent
ZTL to be evaluated to text. This would then be parsed to whatever processes the tag as an attribute called _resulttext . (perhaps?). See the SendmailExample
- attribute
the name of the attribute being passed.
- type
the type of the thing being provided as the value. Examples I can think of include python , perl , int , date , namespace , binding . This type may be ommitted in which case it is taken to be a literal, whatever that means :S
Tag Evalutation
The text content of a ZTL method would be processed from start to finish. Non-tag text would be put in the stream.
When a ZTL tag is encountered, it is evaluated and it's result is returned into the stream.
The evaulation would be as follows (in order):
evaluate all attributes to literals/objects and check for correct type.
execute any initial tag-specific code.
evaluate any tagcontent in the current namespace. Turn the result into an attribute for the tag.
execute the remainder of the tag-specific code returning the result (if any) into the text stream.
Tags
<z:set name="value" name="value" etc />
This is the equivalent of a global REQUEST.set(name ,value) for each name if no tagcontent is supplied
and a dtml-let around the tagcontent if it is supplied.
<z:iterate object="value" other stuff />
<z:recurse object="value" children="method" other stuff />
Equivalents of dtml-in and dtml-tree but with no presentation stuff implemented.
Quicknotes:
render execute if/elif/endif namespace try/except/raise comment
To be filled in when it's not past 11:00pm for ChrisW ;-)
|