[ZPT] Truncating strings

Fernando Martins fmartins at hetnet.nl
Fri Oct 24 13:27:47 EDT 2003


Shane Hathaway wrote:
> 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.

It's just that Fergal's option looks much cleaner than the python: variant.
Your suggestion for prefixes would be the ultimate answer in simplicity but
it messes too much with the well-known concept of path.

Cheers,
Fernando




More information about the ZPT mailing list