velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Novakowski <m...@pandora.com>
Subject Re: Extracting a list of keys from a string based template
Date Thu, 20 Jul 2006 17:27:01 GMT
Here's an idea - to get the keys from the template, you could use the  
decorator pattern to create a wrapper around the context object.   
Have the "get()" and "containsKey()" methods in your wrapper keep  
track of the keys that are being looked up by velocity during the  
evaluate.

I haven't tried it, but I think it might work...

Marc


On 20-Jul-06, at 4:01 AM, Smith, Mike H wrote:

> Hi,
>
>
>
> I'm a Velocity newbie, and am evaluating to see if it can address our
> relatively simple requirements.
>
>
>
> I need to use String based templates. After a bit if digging around I
> found the following function:
>
>
>
> Velocity.evaluate( context, writer, "", templateString );
>
>
>
> This works pretty well for our purposes.
>
>
>
> However I also need to get a list of candidate keys from the template
> String.
>
>
>
> So if my template contains: "$a $b" I need to extract ["a","b"].
>
>
>
> Thanks.
>
> Mike
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message