Christoph Zwerschke wrote:
> Michael Steinfeld wrote:
> > I don't know .. is it just me to spend more time trying to get thing
> > done with kid templates then working with turbogears?
> > I have a project that has been a lot of fun to working except for kid,
> > it occupies the majority of my team and delays my project completion.
>
> I don't think it is so bad. The good thing about Kid is that you can
> keep all the features easily in memory because they are so few. And once
> you understood the concepts and got accustomed to some typical idioms,
> it's pretty easy.
>
> The main problem is the bad error reporting of Kid due to the fact that
> Kid templates are converted to Python modules, and the information about
> the position in the XML file gets lost in this process. Genshi processes
> the templates directly, so it is able to give much better error
> reporting. Anyway, Kid is constantly improving and I'm sure we will
> finally have reasonable error reporting in Kid as well.
>
> Concerning your example where you wanted to do this:
>
> for data in d:
>      if data == "0":
>          print "<td class='lightsout'></td>"
>      else:
>         print  "<td class='lightson'> data </td>"
>
> This is how you would do it in Kid:
>
> <td py:for="data in d"
>      class="${data=='0' and 'lightsout' or 'lightson'}">
>      <span py:if="data!='0'" py:content="data" py:strip="True"/>
> </td>
>
> However, there is another advice: Preprocess your data before you pass
> it to Kid. Either in a separate <?python ... ?> block or completely
> outside the template, in the controller. The Kid template is not the
> place for application logic etc. If the data is preprocessed, everything
> becomes much simpler. E.g. in this case:
>
> <?python d = [
>       data == '0' and ('lightsout', '') or ('lightson', data)
>               for data in d] ?>
> <td py:for="cls, out in d" class="$cls" py:content="out"/>
> 
> Hope that helps.
> 
> -- Christoph


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to