You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Bruce Altner <ba...@hq.nasa.gov> on 2001/11/17 16:10:15 UTC

Re: stringSubstitution()...never mind!

I apologize for answering my own question, but never mind. I took a look at 
the source code and all is clear now. Next time I will do that first.

Thanks,
Bruce



>I apparently need help understaning how to use the stringSubstitution() 
>method in the StringUtils class.  For a test I just wanted to
>replace "!" with "?".
>
>Here is a code snippet from the calling class:
>
>
>         Hashtable rt = new Hashtable();
>         rt.put("!","?");
>         context.put ("utils", new StringUtils());   //so that I can use 
> StringUtils methods
>         context.put("rt",rt); //stringSubstitution requires a Hashtable 
> of substitution values
>
>
>The template I merge with this has the following:
>
>#set ($teststring = "Are you going to Scarboro Fair!")
>$rt
>After substituion "$teststring" becomes 
>"$utils.stringSubstitution($teststring,$rt)"
>
>which comes out this way...
>
>{!=?}
>After substituion "Are you going to Scarboro Fair!" becomes "Are you going 
>to Scarboro Fair!"
>
> From the first line of output I see that the replacement table (rt) is 
> available but the string is not being replaced.
>I must be missing the point of this method entirely. Can anyone explain it?
>
>Thanks,
>Bruce
>
>--
>To unsubscribe, 
>e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: 
><ma...@jakarta.apache.org>
>

_________________________________________________________________
"It's a magical world, Hobbes, ol' buddy...let's go exploring!" ---Calvin

Phone: 202-651-8553
Pager Email:8273479@skytel.com




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>