[ZPT] Truncating strings

Fernando Martins fmartins at hetnet.nl
Sat Oct 25 13:37:09 EDT 2003


Fergal Daly wrote:
> > I don't like so much the quote approaches because it's quite
> common (for me
> > at least) to have single quotes in string: values. (I would have to do
> > frequent escaping)
>
> Are single quotes more common than commas? Would the strings that
> you pass
> into methods be long ones? I would have thought that long strings
> tend to be
> static parts of the HTML doc or are stored in variables. Do you
> have lots of
> python: calls in your current template that include long strings?
>

The cases I recall are in JavaScript function calls (tal:attributes="onclick
string:document.open(${request/URL0}, 'new', 'statusbar,...')") (syntax
probably wrong), which in fact are unlikely to appear in a function call.
There are other situations I don't recall (setting values in forms, maybe),
but I'm sure it's always short strings.

> > > truncate(this/thing, 10, more='...')
> >
> > How about truncate(this/thing, 10, param/more/'...')?
>
> I think
>
> param:more='...'
> param:more=this/thing
>
> might be more suitable. I'm not a Python person so I don't mind too much!
>
> In the end the whole idea is to make it easier to do the simple,
> useful things
> are currently done with a quick "python:". I also think it's
> quite strange
> that you can call methods using TALES but you cannot pass arguments,
>

Yes and also lower the barrier to entry for programmers by relying on a
common paradigm (function calls with the twist they can use paths as
parameters).

Fernando




More information about the ZPT mailing list