[ZPT] Truncating strings

Shane Hathaway shane at zope.com
Fri Oct 24 06:59:36 EDT 2003


On Fri, 24 Oct 2003, fergal at esatclear.ie wrote:

> I said this yesterday but no one replied, so here it is again.
> 
> Just allow arguments to methods
> 
> <span tal:replace="lib/fmt/truncate(container/path/to/var, some/length)">

If you're doing something that sophisticated, you should just write
Python.

<span tal:replace="python:
   lib.fmt.truncate(path('container/path/to/var'), 10)">

Perhaps the resolution to this debate is that Python expressions in
templates ought to be encouraged rather than discouraged.  Python is more
verbose, but it solves a lot of problems, and everyone seems to want to
write Python expressions anyway.  Even if we decide Python expressions are 
good, though, we must never do away with the "python:" expression type 
prefix.  The lack of that prefix is perhaps the biggest flaw in DTML, 
IMHO.

Shane



More information about the ZPT mailing list