[ZPT] Truncating strings

Ian Bicking ianb at colorstudy.com
Wed Oct 22 23:01:54 EDT 2003


On Wednesday, October 22, 2003, at 09:47 PM, Shane Hathaway wrote:
> On Tue, 21 Oct 2003, Ian Bicking wrote:
>> [I think tal:format would imply structure]  But the current access to
>> these sorts of functions through the modules variable is painful at
>> best.  And it seems like the functions in PythonScripts.standard are a
>> little sparse.
>
> Once again, this would be beautifully simple with subpath prefixes.
> Behold:
>
> <span tal:content="var/fmt:truncate/10"></span>
>
> I keep trying to tell everyone why this is so great.  Does anyone 
> listen?
> :-)

Thinking about the same thing, I'd intuitively come up with:

<span tal:content="fmt/truncate/10:var"/>

Which would be equivalent to fmt.truncate['10'](var).  I.e., just use : 
to mean call.  This is a little problematic because : is already being 
used elsewhere (not:, python:), but there are a fixed number of such 
prefixes and they are clearly defined (and can't have a '/' in them).

When I first saw your expression, I actually tried to parse it in just 
that way.  Is there something that your proposal can accomplish that 
simple calling can't?

--
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org




More information about the ZPT mailing list