[ZPT] Truncating strings

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


fergal wrote:
> From: Fernando Martins fmartins at hetnet.nl
>
> > How would you explain in the FAQ why constants and parameter
> names are not
> > allowed? ;-)
>
> Not sure why the smiley, this is a problem.

Just challenging you as it seemed you didn't want it.

> However you could just do
>
> replace="lib/fmt/append(this/thing, string:hello)"
>
> however there is a problem with parsing that. The string: construct has no
> end marker,

The end marker could be the comma. If you need a comma in the string, double
it.

> so you don't know if the string is "hello" or
> "hello)". I would
> suggest allowing " and ' delimited strings in argument lists and also
> treating anything which looks like a number. So 10 would be the
> 10, not the variable called "10". Anyone using a variable called 10
deserves
> to be shot anyway.

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)

[...]
> As for parameter names, you can't have everything. I'd suggest that any
> method being called from a template that needs named paramters is
> going way beyond what you should be doing in a template.
>
> Although if you really really wanted then you could correctly parse
>
> truncate(this/thing, 10, more='...')
>

How about truncate(this/thing, 10, param/more/'...')?

Fernando




More information about the ZPT mailing list