[Zope] TALES expression

Tino Wildenhain tino at wildenhain.de
Wed Jul 16 06:34:27 EDT 2008


Garito wrote:
> Hi!
> Please consider this TALES expression:
> 
> <div class="DataPrevista" tal:content='here/getDataInici | string: nosta' />
> 
> If I try this other: <div tal:content='string:${here/getDataInici}' /> 
> the result is <div>None</div>
> 
> Then the first one will render the alternate expression isn't it?
> 
> Then with it renders <div class="DataPrevista" /> ?

Сто? ;-)

You should check the tales documentation. the pipe symbol |
means a logical "or", in effect if the left expression resolves
to "non existent", None, empty object,... (generally python False)
the right part of it is evaluated.

In the special case it probably is nicer to use:

<div class="DataPrevista" tal:content="here/getDataInici | 
default">nosta</div> instead so the fallback value is part
of the template (TAL is meant to be design by example)

I would also recommend not mixing " and ' for attributes and
maybe in the long run sticking to english language names for
your objects makes it easier to ask on mailinglists.

Regards
Tino

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3241 bytes
Desc: S/MIME Cryptographic Signature
Url : http://mail.zope.org/pipermail/zope/attachments/20080716/bcb4460d/smime.bin


More information about the Zope mailing list