Now that you've got the skinny on variables and conditional statements, expand your knowledge of the ZPT universe with this discussion of TAL loops, dynamically-generated attributes and error handlers.
You can add primitive error-handling to your templates via the special "on-error" attribute, which allows you to specify a simple error message that is displayed when TAL encounters an error. Consider the following example:
<font color="red" size="2" face="verdana"
tal:on-error="string:Form
input error"
tal:attributes="color request/color; size request/size; face
request/face">
Sticks and stones will break my bones </font>
In this case, since my code requires the "size", "face" and "color" input variables
to be specified as input parameters via the URL (notice that I have not used the "default" condition here, as I did in the previous example), an error will be generated if these variables are not present. However, rather than displaying the standard Zope error message,
I can intercept the error with TAL's "on-error" attribute, and replace it with my own, simpler error message.
"on-error" attributes are processed in a hierarchical manner, with TAL recursing upwards from the source of the error until it finds an "on-error" error handler. In the following example, even though the error is generated by the innermost <font> element, the error message generated comes from the outermost <div> element.
<div tal:on-error="string:Form input error">
<b><font color="red" size="2"
face="verdana"
tal:attributes="color request/color; size request/size;
face
request/face"> Sticks and stones will break my bones </font> </b> </div>