[Zope] dtml-in iteration over a string.split

Itamar Shtull-Trauring itamars@ibm.net
Tue, 14 Mar 2000 19:13:11 +0200


Daniel.Weber@SEMATECH.Org wrote:
> 
> >
> > This is untested but it should do the trick:)
> >
> > <dtml-if "_.int(sequence-size) > 1">
> 
> This gives a key error as well.  To summarize what I'm trying to do:
> 
> <dtml-in "_.string.split(string_with_1_or_more_words)">
>   <dtml-if "we_have_>_1_items">
>    we have <dtml-var what_is_this_var?> items
>   <dtml-else>
>    we have only 1 item
>   </dtml-if>

<dtml-let items="_.string.split(string_with_1_or_more_words)">
<dtml-let numitems="_.len(items) > 1">
<dtml-if "numitems > 1">
we have &dtml-numitems; items
<dtml-else>
we have one item
</dtml-if></dtml-let></dtml-let>

Or you can access sequence-size as _['sequence-size']:
<dtml-if "_.int(_['sequence-size']) > 1">
-- 
Itamar S.T.  itamars@ibm.net