[Zope] simple dtml-if question

Patrick Lewis pl@teleport.com
Wed, 26 Jul 2000 12:13:35 -0700


On Wed, Jul 26, 2000 at 10:14:09AM -0700, joel grimes wrote:
> How do I do this?
> 
> I have a table with a field called SerialNumber.  I want to test it for null 
> and return a non-breaking space if it's null.
> 
> Here's what I tried:
> 
> <dtml-if "SerialNumber = null">&nbsp;
> <dtml-else><dtml-var SerialNumber>
> </dtml-if>
> 

If null means an empty string (e.g. '') or the Python value None, the
first line should be:

<dtml-if "not SerialNumber">nbsp;

or perhaps (empty string only)

<dtml-if "SerialNumber == '' ">nbsp;

It really helps to remember that anything inside double quotes gets
evaluated as a Python expression.  You were initially trying to assign the
value of null (which may have not actually existed) to SerialNumber.

-- 
Patrick Lewis <pl@teleport.com>