[Zope-CMF] TAL: Semantics of the | operator inside tal:condition

Andreas Jung lists at andreas-jung.com
Sun Jan 18 15:29:27 EST 2004


While debugging a problem in Plone 2 I came across some code that
uses tal:condition="expr1|expr2"  that was never executed  if expr1
evaluated to False. Here is a small example that show the problem

<div tal:define="a python: []; b python: [1,2,3]">
  <span tal:condition="a|b">
    hello world
  </span>
</div>

Running the template outputs nothing instead of 'hello world'

Is there a reasonable explanation for this?

Also look at this code here:

<div tal:define="a python: None; b python: 42; c a|b">
<span tal:content="c" />
</div>

One would expect that 'c' is assigned to 42. At least this was the opinion
of some qualified plone developers. The TAL documentation is not completely
clear at this point. I know that the code can be rewritten using test()
but I would like to know about the semantics of the | operator in this case.

Thanks,
Andreas





More information about the Zope-CMF mailing list