Home arrow Zope arrow Page 3 - ZPT Basics (part 2)

The Number Game - Zope

Dig deeper into the world of ZPT with examples andillustrations of how to create, manipulate and use variables andconditional tests in your templates.

TABLE OF CONTENTS:
  1. ZPT Basics (part 2)
  2. A Little Male Bonding
  3. The Number Game
  4. A Question Of Scope
  5. Switching Things Around
  6. Comparing Apples and Oranges
  7. If It's Thursday, It Must be Italy
  8. Submitting To The King
  9. Looking Ahead
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 13
September 25, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

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


 
 
>>> More Zope Articles          >>> More By Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ZOPE ARTICLES

- Creating Zope Products
- Plone Content Types With Archetypes
- Flat User Management in Zope
- Creating Basic Zope Applications
- Getting started with Zope for Linux and Sola...
- ZPT Basics (part 4)
- ZPT Basics (part 3)
- ZPT Basics (part 2)
- ZPT Basics (part 1)
- Exception Handling In DTML
- DTML Basics (part 4)
- DTML Basics (part 3)
- DTML Basics (part 2)
- DTML Basics (part 1)
- Using Zope With Apache

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: