[ZPT] Deafening chirping of crickets

Evan Simpson evan at 4-am.com
Fri Apr 18 16:30:27 EDT 2003


Evan Simpson wrote:
> It will, of course, be much more common to do simple 2- or 3-way choices 
> within a single group.

...and after reading Jaime's posting, I should really reiterate what 
this common case is, and looks like.

In Python:

  if A:
      do A stuff
  elif B:
      do B stuff
  else:
      do something else

In TAL:

  <div tal:condition-group="g1">
      <span tal:condition="g1 A">do A stuff</span>
      <span tal:condition="g1 B">do B stuff</span>
      <span tal:condition="g1 default">do something else</span>
  </div>

Without condition-group, the TAL might need to be written:

  <span tal:condition="A">do A stuff</span>
  <span tal:condition="python:not A and B">do B stuff</span>
  <span tal:condition="python:not A and not B">do something else</span>

...depending on the logical relationship of A and B.  Unless we 
precompute A and B, we're also going to be doing duplicate calculations, 
slowing things down.

Cheers,

Evan @ 4-am




More information about the ZPT mailing list