velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Can I Create a Template with the Template Text Itself?
Date Wed, 14 Jun 2006 19:59:24 GMT
This sounds good to me.  And some of this may have already been done
for you.  Search the archives of the user and/or dev lists for
"StringResourceLoader".  I haven't looked at it myself, so i can't
recall the details offhand, but i'm sure it would be a good place to
look.

On 6/14/06, Keith R. Bennett <kbennett@sms-fed.com> wrote:
> 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
>
>

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