|
the "Cheetah files" (part 1): msg#00009python.cheetah
hi there, i just want to share a nice "usage pattern" that i started to use recently, nothing outstanding. one tipcal task is to accomplish is: ''loop over a sequence and display data, if sequence is empty show a notice.'' say you have to display a HTML bulleted list with a series of message titles, until recently i've always written: #if $seq <ul> #for $item in $seq <li><a href="read?id=$item.id">$item.title</a></li> #end for </ul> #else <p class="info">No message found.</p> #end if ugly and messy. what about a: <ul> #for $item in $seq <li><a href="read?id=$seq.id">$seq.title</a></li> #end for </ul> #unless $seq <p class="info">No message found.</p> #end unless you spare one level of indentation. yes, if the sequence is empty you generate a <ul></ul> pair, but you can always write: <ul> #for $item in $seq <li><a href="read?id=$seq.id">$seq.title</a></li> #end for #unless $seq <li class="info">No message found.</li> #end unless </ul> i'm interested in your tricks too. later, deelan ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Is Cheetah thread safe?, Mike Orr |
|---|---|
| Next by Date: | Re: the "Cheetah files" (part 1), Mike Orr |
| Previous by Thread: | Is Cheetah thread safe?, JZ |
| Next by Thread: | Re: the "Cheetah files" (part 1), Mike Orr |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |