ZPT Basics (part 2) - The Number Game (Page 3 of 9 )
Remember how I told you TALES expressions need not only be paths, butcan be Python expressions too? Here's an example of how that might work:
<h1>10 * 34 is <i tal:define="product python:10*34"tal:replace="string:$product">Product here</i>.</h1>
In this case, instead of using the "string" keyword, I've used the"python" keyword, which instructs Zope to evaluate the Python expressionand store the result in the variable "product". Here's the output:
10 * 34 is 340
You can define more than one variable at a time as well - take a look:
<h1>The name's <i tal:define="firstname string:Robin;lastnamestring:Hood" tal:content="string:$lastname, $firstname $lastname">namehere</i>.</h1>
As you can see, in order to define two variables in a single statement,you simply need to separate them with a semi-colon (;). Here's theoutput:
The name's Hood, Robin Hood.
Next: A Question Of Scope >>
More Zope Articles
More By Harish Kamath, (c) Melonfire