[ZPT] Truncating strings

Fernando Martins fmartins at hetnet.nl
Thu Oct 23 19:00:09 EDT 2003


Fernando Martins wrote:
> The solution proposed previously
>
> <span tal:replace="var" tal:format="formatters/truncate">
>
> solves all the problems except support for several parameters. The cost is
> apparent overtyping. A possible compromise is:
>
> <span tal:replace="var; fmt.truncate(10, more='...')">
>
> But, quite frankly, I don't feel convinced about this need. I really would
> like to see a convincing example.
>

Ironically, I just came across the relevance of prefixes in:

http://mail.zope.org/pipermail/zope3-dev/2003-September/008482.html

where Shane wrote:
"FWIW, I would like to see this debate resolved through the use of
recently introduced mechanisms.  A folder full of Python scripts is
equivalent to a Python module containing only functions, therefore, we
should provide a simple UI for site developers to write persistent
modules.  Then we should provide an easy way to call persistent modules
from templates; the new prefix stuff should be pretty effective for that."

Unfortunately, I can't digest the prefixes and believe that scripters will
easily take it.

What's exactly wrong with a standard function call using a path(s) as a
parameter:

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

Cheers,
Fernando




More information about the ZPT mailing list