Fw: [Zope] inelegant repetition of ZPT code

Andre Meyer a.meyer at hccnet.nl
Wed Nov 26 03:43:42 EST 2003


----- Original Message -----
From: "Andre Meyer" <a.meyer at hccnet.nl>
To: "Wilson, Derek" <dwilson at abrazohealth.com>
Sent: Wednesday, November 26, 2003 9:43 AM
Subject: Re: [Zope] inelegant repetition of ZPT code


> Well, I was trying with ZPT-only and struggled, because you end up with
> either malformed html (tr twice) or repetition. The python solution
> mentioned below works perfectly well in ZPT, except for the missing
> parentheses for odd() ;-)
>
> ----- Original Message -----
> From: "Wilson, Derek" <dwilson at abrazohealth.com>
> To: "Allen" <aschmidt at fredericksburg.com>
> Cc: "Phil Harris" <phil at harris-family.info>; "Zope list" <zope at zope.org>
> Sent: Wednesday, November 26, 2003 3:51 AM
> Subject: RE: [Zope] inelegant repetition of ZPT code
>
>
> > well, Allen, Andre was looking for a ZPT code to do it, not python.
So...
> :-P~~
> >
> > -----Original Message-----
> > From: Allen [mailto:aschmidt at fredericksburg.com]
> > Sent: Tue 11/25/2003 5:45 PM
> > To: Wilson, Derek
> > Cc: Phil Harris; Zope list
> > Subject: Re: [Zope] inelegant repetition of ZPT code
> >
> >
> >
> > I don't get it! This answer posted earlier works great.... and my
nickname
> is DTML-man!
> >
> > <tr tal:attributes="bgcolor python: test(repeat['item'].odd, 'white',
> 'lightgray')" />
> >
> > -Allen
> >
> >
> > Wilson, Derek wrote:
> >
> > > try this...
> > >
> > > <table tal:repeat="item here/listItems">
> > >
> > >    <tr bgcolor="white" tal:omit-tag="not:repeat/item/even">
> > >    <tr bgcolor="lightgray" tal:omit-tag="not:repeat/item/odd">
> > >
> > >                     <td>...</td>
> > >
> > >    </tr>
> > >    </tr>
> > >
> > > </table>
> > > -----Original Message-----
> > > From: Phil Harris [mailto:phil at harris-family.info]
> > > Sent: Tue 11/25/2003 4:23 PM
> > > To:   Zope list
> > > Cc:
> > > Subject:      Re: [Zope] inelegant repetition of ZPT code
> > > That won't work because you have badly formed html in there.
> > >
> > > The <tr>s are badly nested with the spans, you must have correctly
> > > formed html when using TAL.
> > >
> > > Phil
> > > On Tue, 25 Nov 2003 16:15:05 -0700
> > > "Wilson, Derek" <dwilson at abrazohealth.com> wrote:
> > >
> > > dwilson> How about:
> > > dwilson>
> > > dwilson> <table>
> > > dwilson>     <span tal:repeat="item here/listItems">
> > > dwilson>        <span tal:condition="repeat/item/even"><tr
> bgcolor="white"></span>
> > > dwilson>        <span tal:condition="repeat/item/odd"><tr
> bgcolor="lightgray"></span>
> > > dwilson>                    <td>...</td>
> > > dwilson>         </tr>
> > > dwilson>     </span>
> > > dwilson> </table>
> > > dwilson>
> > > dwilson> I haven't tested it, but it should work.
> > > dwilson>
> > > dwilson>      -----Original Message-----
> > > dwilson>      From: Andre Meyer [mailto:a.meyer at hccnet.nl]
> > > dwilson>      Sent: Tue 11/25/2003 1:52 PM
> > > dwilson>      To: Zope Mailing List
> > > dwilson>      Cc:
> > > dwilson>      Subject: [Zope] inelegant repetition of ZPT code
> > > dwilson>
> > > dwilson>
> > > dwilson>
> > > dwilson>      Hi Zopers
> > > dwilson>
> > > dwilson>      Another detail that bugs me: how can I translate the
> following dtml code
> > > dwilson>      to zpt. It colours table rows in grey/white
alternatively.
> Is the zpt
> > > dwilson>      version below the only way? It is clearly very inelegant
> to repeat code.
> > > dwilson>
> > > dwilson>
> > > dwilson>      DTML
> > > dwilson>
> > > dwilson>      ...
> > > dwilson>      <table>
> > > dwilson>          <dtml-in listItems>
> > > dwilson>              <tr <dtml-if
> sequence-even>bgcolor="lightgray"</dtml-if>>
> > > dwilson>                  <td>...</td>
> > > dwilson>              </tr>
> > > dwilson>          </dtml-in>
> > > dwilson>      </table>
> > > dwilson>
> > > dwilson>
> > > dwilson>      ZPT
> > > dwilson>
> > > dwilson>      ...
> > > dwilson>      <table>
> > > dwilson>          <span tal:repeat="item here/listItems">
> > > dwilson>              <tr bgcolor="white"
> tal:condition="repeat/item/even">
> > > dwilson>                  <td>...</td>
> > > dwilson>              </tr>
> > > dwilson>              <tr bgcolor="lightgray"
> tal:condition="repeat/item/odd">
> > > dwilson>                  <td>...</td>
> > > dwilson>              </tr>
> > > dwilson>          </span>
> > > dwilson>      </table>
> > > dwilson>
> > > dwilson>
> > > dwilson>      thanks and best wishes
> > > dwilson>      Andre
> > > dwilson>
> > > dwilson>
> > > dwilson>
> > > dwilson>      _______________________________________________
> > > dwilson>      Zope maillist  -  Zope at zope.org
> > > dwilson>      http://mail.zope.org/mailman/listinfo/zope
> > > dwilson>      **   No cross posts or HTML encoding!  **
> > > dwilson>      (Related lists -
> > > dwilson>       http://mail.zope.org/mailman/listinfo/zope-announce
> > > dwilson>       http://mail.zope.org/mailman/listinfo/zope-dev )
> > > dwilson>
> > > dwilson>
> > >
> >
> >
> >
> >
>
>
> --------------------------------------------------------------------------
--
> ----
>
>
> > _______________________________________________
> > Zope maillist  -  Zope at zope.org
> > http://mail.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://mail.zope.org/mailman/listinfo/zope-announce
> >  http://mail.zope.org/mailman/listinfo/zope-dev )
> >
>




More information about the Zope mailing list