[stringtemplate-interest] String manipulations

John Snyders jjsnyders at rcn.com
Fri Sep 22 07:12:51 PDT 2006


Hi Oliver,

I'm new to this list and I didn't see your post.
I was beginning to suspect that dup was the problem.

I can't think of any reason why dup wouldn't copy the renderers. As it is
now it means that the only  time assigning a specific renderer to a
StringTemplate would work is if it is the top level template (from your
code's perspective the one you are calling toString on).

I assume you made the change to dup. How do we go about giving this code
back so that it can be included as a bug fix?

Or can someone explain why dup should not copy the renderers?

>From Oliver's original post: "For me, that's just not practical as it does
not work for
attribute properties and it would be just too awkward to add each
property as a first-class attribute."

I did not think there was anything special about properties in terms of how
they are processed by templates so a wrapper class would work just as well
for a property. You just have to make sure that the value of your property
contains the wrapped class {setDate(new WrappedDate(somedate)); } It doesn't
happen automatically as in the example where a derived StringTemplate is
used. Perhaps this is what you ment that it is not automatic and you can't
change all your model objects.

Looking at dup makes me wonder about the performance of StringTemplate it
seems that templates will be copied many times. But this is a different
subject and I will check the archives first.

Thanks,
-John

-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org
[mailto:stringtemplate-interest-bounces at antlr.org]On Behalf Of Oliver
Flege
Sent: Friday, September 22, 2006 4:40 AM
To: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] String manipulations


Hi,

John Snyders wrote:
>
> I had the idea that I could use a template to format strings rather than
> create a wrapper around Strings.
> I would create a template and add it to a group the template would
> simply expand its argument.
> Registering a renderer with just this template should cause strings to
> be uppercased.
...
> Does anyone know why what I am doning isn't working? I'm using version
3.0.

I had the same idea some time ago:
http://www.antlr.org:8080/pipermail/stringtemplate-interest/2006-July/000512
.html

In ST 3.0, your example is not working due to the same reason I mentioned in
my posting:
The attribute renderers are not copied when a template is duplicated to be
used in an evaluation
-- and no, I don't have any idea why this is not done as I never got any
response.

Although ST is a great templating language/engine, imho it also suffers from
the
lack of a real open source infrastructure: having just one developer for
each language variant
(at least it seems to be that way), no online source code repository with
version control,
no issue tracking system, etc.

The only way I found to deal with ST's deficiencies was to grab the source
code,
put it into our company's code repository, and modify it according to our
needs.

BTW: The source code is really easy to understand, so there is no reason not
to modify it :)

 Oliver







_______________________________________________
stringtemplate-interest mailing list
stringtemplate-interest at antlr.org
http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest


More information about the stringtemplate-interest mailing list