velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith R. Bennett" <kbenn...@sms-fed.com>
Subject Can I Create a Template with the Template Text Itself?
Date Wed, 14 Jun 2006 18:40:54 GMT
Hello...

I would like to do *both of* the following with my templates:

* use a template created from a string created in memory at runtime (as 
one can do with evaluate()).

* have template caching (as one can do with template.merge()).

In other words, I'd like to create a cached template by providing the 
template text itself (rather than a filespec, etc.), thereby bypassing 
Velocity's resource management system.

If Velocity provides caching for files, whose contents may change over 
time, why would it not provide caching for strings whose contents would 
*never* change?

This would enable the programmer to:

1) embed template strings in test classes (without the need to create a 
temporary file with their contents).  (Using evaluate() just for testing 
is not acceptable because I want to exercise the code that the user 
would be using.)

2) support template strings that are themselves generated at runtime

3) support nonstandard data sources

I realize that a workaround would be to create a temporary file with the 
string's content, but that is convoluted and I'd rather avoid it.

Thanks for any help you can offer.

- Keith


---------------------------------------------------------------------
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