Both of the examples you provide do not make sense to me...
> {{ name | lower }}, or {{ identity.is_anonymous() | yes_no }}.
name.lower() will work as long as name is a string, and you can
easily perform "tuple"-like actions with (my favorite):
identity.is_anonymous() and "Yes" or "No"
Or:
['No', 'Yes'][identity.is_anonymous()]
The KidRecipes section of their Trac (http://www.kid-templating.org/
trac/wiki/KidRecipes) features several solutions to problems that
require conditionals like that - e.g. http://www.kid-templating.org/
trac/wiki/AlternatingRowStylesRecipe
Fun doesn't enter into my code by inventing new syntax (or pulling
syntax from other languages). Fun is readable code which any Joe can
understand. What if you want to pass additional arguments to a
filter? It is no more difficult to create a library of useful
functions (which TG is slowly doing with the tg. namespace, like
tg.url) than it would be to implement filters.
Why is passing a library of useful functions inside a single
namespace (e.g. the tg. namespace) to KID or Genshi bad? Filters go
against the Zen of Python: (Yeah! I brought the Zen into the
thread! :^P )
* Explicit is better than implicit.
* Simple is better than complex.
* Special cases aren't special enough to break the rules.
* There should be one-- and preferably only one --obvious way to do it.
* Namespaces are one honking great idea -- let's do more of those!
No sir, I can't say I like it. Filters, that is. :P (Oh, and if
you want it prettier, you -can- do this:)
linebreaks( escape( story.text ))
Or, better yet, have a single function to format BBS text: (limiting
available HTML, converting BBcode to HTML, linebreaks to </p><p> and
<br/> tags as nessicary, turning links into links, etc.)
bbstext( story.text )
...or you could implement a custom subtype of unicode that implements
a render method:
story.text.render()
^_^; Implementing the sub-type is what I'd do...
Matthew Bevan, Systems Administrator
Top Floor Computer Systems Ltd.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---