[Zope] conditionals inside dtml-let expressions

Casey Duncan c.duncan@nlada.org
Thu, 18 Oct 2001 14:05:32 -0400


On Thursday 18 October 2001 12:56 pm, Mitchell Model allegedly wrote:
> Is there a straightforward way to bind one of two values to a let
> variable depending on the value of another variable?  In C/C++/Java I
> would use the ?: operator, but Python doesn't have that.  Or should I
> just bind the variable to None then set it later with something like
>
>
> <dtml-let var=None>
>
>   <dtml-if "testvar==targetval">
>
>     <dtml-var expr="_.set(var, 'yes')>
>
>   <dtml-else>
>
>     <dtml-var expr="_.set(var, 'no')>
>
>   </dtml-if>
>
> </dtml-let>


Perhaps:

<dtml-let var="['no','yes'][testvar==targetval]">
  ...
</dtml-let>

would do the trick.

/---------------------------------------------------\
  Casey Duncan, Sr. Web Developer
  National Legal Aid and Defender Association
  c.duncan@nlada.org
\---------------------------------------------------/