velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Batch a template?
Date Fri, 19 May 2006 14:42:04 GMT
Don't use the evaluate() method.  That's a shortcut method that is
more expensive than the standard methods.  You just need to use
Velocity in the standard way:

http://jakarta.apache.org/velocity/docs/developer-guide.html#The%20Fundamental%20Pattern

Then the template can be parsed and cached for immediate re-use with
different contexts.

On 5/18/06, tlecavel.ml <tlecavel.ml@laposte.net> wrote:
> Hello,
>
> The process to evaluate a template is quite long and take many
> ressources on the CPU. Is it possible to "batch" a template
> with a set of different context to save time?
>
> I explain: at this time a have a function that do something like:
>
>   StringBuffer buffer = new StringBuffer();
>
>   Velocity.init();
>   VelocityContext context = new VelocityContext(voContext);
>
>   StringWriter w = new StringWriter();
>
>   Velocity.evaluate(context, w,
>        getConfig().getProperty("velocity.logFile"),
>        template);
>
>   buffer.append(w);
>   return buffer;
>
> And this block is called about a hundred of times where only
> voContext is modified. Is there a way to evaluate just once
> the template and then give Velocity a list of context to treat?
>
> Thanks for your help.
>
> -- Thomas.
>
> Accédez au courrier électronique de La Poste : www.laposte.net ;
> 3615 LAPOSTENET (0,34 €/mn) ; tél : 08 92 68 13 50 (0,34€/mn)
>
>
>
>
> ---------------------------------------------------------------------
> 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