[ZPT] Truncating strings
Fernando Martins
fmartins at hetnet.nl
Thu Oct 23 14:07:24 EDT 2003
Shane Hathaway wrote:
> Once again, this would be beautifully simple with subpath prefixes.
> Behold:
>
> <span tal:content="var/fmt:truncate/10"></span>
>
I believe this has the following problems:
- it overloads the semantic of paths: besides being an obvious reference to
an object, to which everyone is familiar with, it supports a call to a
function and a parameter. No, the colon doesn't really help. What was once
simple becomes complex;
- bad readability with the associated problems;
- it supports only one parameter (it can be expanded by relying on a fixed
sequence of parameters which is a bad idea anyways);
- doesn't use typical function call syntax (recognisable by everyone);
and it really adds only one benefit: avoid calling a one-line script. Or am
I missing others?
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.
Cheers,
Fernando
More information about the ZPT
mailing list