didge,

Thanks for info. I didn't know VPP project. Now I have read the document
at http://vpp.sourceforge.net, but not sources.

didge wrote:
> You may also be interested in VPP (http://vpp.sourceforge.net).  It provides
> the following:
> 
> - VPPFilter, a FilterReader supporting VTL.
> - VPP, an extenson of the Copy task integrating VPPFilter.
> - VPPJavaC, an extension of the Javac task also integrating VPPFilter for
> preprocessing .java files before compilation using VTL.

I like your idea on implementing template processing as a filter.
I wonder I should change my VelocityTask implementation,
but currently I am a very beginner about ant filterchains.
What do you think? > all.

> 
> In addition to being able to use VTL, you also have access to all of your
> Ant project properties via the key $ant.  For example, you can get your
> project's name with $ant.get("ant.project.name") in your templates.

To provide similar functions, I think it maybe useful if the Project and the
current Task instance are automatically put into the velocity context with
key like "project" and "task" respetively. You can get a project property 
with $project.getProperty(propertyName). Well, but I don't think of cases
I actually use these values at the moment.

> 
> In addition to the Anakia ant task, Velocity also supports Texen, a simple
> ant task that launches Velocity using a 'control template'.

Again, thanks for info. I didn't notice the texen task. But after looking at
TexenTask.java, I think this is too simple to fill my needs.
Texen task can only deal with one template file. I want a fileset.
And texen task populate a velocity context by values in property files.

My plan is to put most of context data in separate velocity template file
such as "config_a.vm" and "config_b.vm", which are selectively included
in the main template "main.vm" like below:
    #include("$configfile")

And you can select which file to include in a velocity task like:
    <velocity todir="c" propertyfile="velocity.properties">
      <velocitycontext>
        <contextdata key="configfile" value="config_a.vm" if="SOME_PROP"/>
        <contextdata key="configfile" value="config_b.vm" unless="SOME_PROP"/>
      </velocitycontext>
      <fileset dir="a">
        <include name="**/*.vm"/>
      </fileset>
      <mapper type="glob" from="*.vm" to="*.html"/>
    </velocity>

Or if you set the ant property "configfile", you can write:
    <velocity todir="c" propertyfile="velocity.properties">
      <velocitycontext>
        <contextdata key="configfile" value="$configfile"/>
      </velocitycontext>
      <fileset dir="a">
        <include name="**/*.vm"/>
      </fileset>
      <mapper type="glob" from="*.vm" to="*.html"/>
    </velocity>

It is more configurable to set context data in velocity template files than in
plain old property files, because you can use all velocity features.

Also you can put an instance of the class name specified like:
        <contextdata key="str" classname="my.package.StringTool"/>
The class must have public non-argument constructor. If the class has
public setContext(org.apache.velocity.context.Context) method, it is
invoked by reflection.

With these features, I think you can setup context data almost arbitarily.

> 
> The current release of vpp is licensed under LGPL, but I will be moving the
> next release to a BSD license soon.

Do you plan to submit your work to included in Ant project? If yes,
it might be better to merge both features and implementations.

--
)Hiroaki Nakamura) [EMAIL PROTECTED]



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

Reply via email to