logo       

Re: the "Cheetah files" (part 1): msg#00012

python.cheetah

Subject: Re: the "Cheetah files" (part 1)

On Sun, Oct 05, 2003 at 08:26:55PM +0200, deelan wrote:
> ouch, this is not as clear as my solution. see mike, most of the times
> i don't have a simple list to display, i have a list with a text an
> hyperlink and a datetime object to format for each item or a table row
> to populate... that's why i prefer to directly loop over the sequence
> and do whaterver is more appropriate for the context.

It sounds like to do exactly what you'd want would require a new
directive. But I can't think of any way that's cleaner than the

#if <UL> #for <LI> #end for </UL> #else Sorry, Charlie! #end if

model you posted. The ifNotMessage could be multiline too, so
it doesn't fit easily into a directive attribute.

#for could grow a section for "if list is empty", but we can't call
it #else because Python uses that clause for another purpose. And
we don't want Python-lookalike directives behaving differently than
in Python. And actually implementing an "if empty" portion in #for
would be a lot of work. Since the "list" can be any iterable, you'd
have to prefetch the first element specially and do something different
if it didn't exist. And even if we did this, there's no place for
<UL> and </UL> -- not unless we added two more #for portions for
"before" and "after". It starts getting really complicated, and a
standard #for combined with #if/else or #unless starts looking the
epitome of readability by comparision.

--
-Mike Orr (aka. Sluggo), mso@xxxxxx (iron@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise