[stringtemplate-interest] String manipulations
Terence Parr
parrt at cs.usfca.edu
Mon Sep 25 10:53:02 PDT 2006
On Sep 23, 2006, at 7:11 AM, John Snyders wrote:
> Here is the change I made to StringTemplate.java
>
> It is just the one line added to the end:
> to.attributeRenderers = from.attributeRenderers;
Fixed. Thanks.
> Then in your templates you can use
> $upperCase(it=name)$
> or
> $name:upperCase()$
Yes, but doesn't that uppercase all strings? Calling that upperCase
template makes no sense to me...sorry. Can you explain how that
gives you control? You could do $name:upperCase()$ and then have a
renderer that sense what template it's in:
public class UpperCaseRenderer implements AttributeRenderer
{
public String toString(Object o)
{
if (o instanceof String && template is "upperCase")
{
String s = (String)o;
return s.toUpperCase();
}
return o.toString();
}
}
But you don't know what the surrounding template is :(
Ter
More information about the stringtemplate-interest
mailing list