On Wed, 2002-03-13 at 02:26, Christian Trutz wrote:
> Hello Velocity community,
> 
> I am new to this mailing list, my name is Christian Trutz and I am a graduate 
> student (mathematics) at University Bonn in Germany. Velocity is for me a 
> cool and useful tool and I want to contribute a little. 
> 
> In the actual CVS tree there is a incomplete 
> org.apache.velocity.runtime.compile.Compiler class. This class wants to 
> compile a template via BCEL. I think it's better to generate first a java 
> file and then compile this with an usual compiler. What I mean:
> 
> 
> Velocity file:
> -----------
> Hello $foo
> -----------
> 
> after "compilation" you get something like this:
> 
> ----------------------------------------------------------
> public class CompiledTemplate {
> 
>     public void merge( Context context, Writer writer) {
>            
>                 writer.write("Hello ");
>                 writer.write( context.get( "foo" ) );
>     }
> }
> --------------------------------------------------------

I disagree, you're going to get into all the nasty problems of
generating source and compiling the sources in your deployed
environment.
 
> Is this a good idea???
> 
> Is anybody working on a Velocity template compiler?

I have thought about it a lot but haven't done much. Also realize that
with the current internal structure of velocity it is not possible to
make an efficient compiler because the types of the objects in the
context are not assumed to be static. By that I mean if you 'person' in
the context, during one rendering that can be a Person object, but on
the next it can be a Hashtable.

So you could make a compiler but there is a severe limitation.

> The AST (see JJTree) implemets the visitor pattern and any AST node has a 
> render method ... why? Is rendering with a visitor not so good?
> 
> 
> Christian
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- 
jvz.

Jason van Zyl
[EMAIL PROTECTED]

http://tambora.zenplex.org


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

Reply via email to