Hi Geir,

It looks like the same thing. Is this little class of any help?
(You probably have a dozen of little classes like this.)


Have fun,
Paulo Gaspar

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 4:11 AM
>
>
> On 11/28/01 9:35 PM, "Paulo Gaspar" <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> >
> > In my code I use a small utility class to do something like
> > org.apache.velocity.app.Velocity.evaluate()
> > but without parsing the template String every time I want to
> > render the template.
>
> I've been wanting to add a helper method to Velocity and
> VelocityEngine that
> is like evaluate but returns a Template.
>
> Then you, the application programmer, can reuse them, and manage their
> storage any way you want - for example storing them in a map or something.
>
> I want to do that anyway - would that serve the same purpose as this? Or
> could you take advantage of it?
>
> geir
>
> > This class - appended to this message - is a simplification
> > from my code, was not tested and was made for a older
> > version of Velocity.
> >
> > So, the questions are:
> > - Is someone interested on this little thing?
> > - Am I using the right classes, i.e.: should I really use
> >    org.apache.velocity.runtime.RuntimeInstance
> >  or should I use something else?
> >
> > If you are interested, I will fix it according to the experts
> > remarks, test it and post it.
> >
> >
> > Have fun,
> > Paulo Gaspar
> >
> >
> > http://www.krankikom.de
> > http://www.ruhronline.de
> >
> >
> > import java.io.Writer;
> > import java.io.StringReader;
> > import java.io.Reader;
> > import java.io.StringWriter;
> >
> > import org.apache.velocity.context.Context;
> > import org.apache.velocity.context.InternalContextAdapterImpl;
> > import org.apache.velocity.runtime.RuntimeInstance;
> > import org.apache.velocity.runtime.parser.node.SimpleNode;
> > import org.apache.velocity.runtime.parser.ParseException;
> >
> >
> > class StaticTemplate
> > {   private RuntimeInstance  m_runtimeInstance;
> >   private SimpleNode       m_nodeTree = null;
> >   private String           m_logTag;
> >
> >   protected StaticTemplate(RuntimeInstance i_runtimeInstance, String
> > i_logTag, Reader i_reader)
> >   throws ParseException
> >   {   super();
> >
> >       m_logTag          = i_logTag;
> >       m_runtimeInstance = i_runtimeInstance;
> >       m_nodeTree        = m_runtimeInstance.parse(i_reader, m_logTag);
> >   }
> >
> >   protected StaticTemplate( RuntimeInstance i_runtimeInstance,
> >                             String i_logTag, String i_templateText
> >                           )
> >   throws ParseException
> >   {   this(i_runtimeInstance, i_logTag, new
> StringReader(i_templateText));
> >   }
> >
> >   private void render(Writer o_writer, Context i_ctx)
> >   throws Exception
> >   {   InternalContextAdapterImpl ica = new
> > InternalContextAdapterImpl(i_ctx);
> >       ica.pushCurrentTemplateName(m_logTag);
> >       m_nodeTree.init(ica, m_runtimeInstance);
> >
> >       try
> >       {   m_nodeTree.render(ica, o_writer);
> >       }
> >       finally
> >       {   ica.popCurrentTemplateName();
> >       }
> >   }
> >
> >   public String render(Context i_ctx)
> >   throws Exception
> >   {   Writer wrt = new StringWriter();
> >       render(wrt, i_ctx);
> >       return wrt.toString();
> >   }
> > }
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
>
> --
> Geir Magnusson Jr.                                     [EMAIL PROTECTED]
> System and Software Consulting
> "He who throws mud only loses ground." - Fat Albert
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to