velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "didge" <>
Subject RE: a PP for Velocity (Was RE: CPP like interface to Velocity)
Date Wed, 18 Dec 2002 11:05:15 GMT
VPP will do nicely for processing sets of files selected via filtersets in
ant.  Texen isn't as well suited because it doesn't do any input selection,
it assumes that a sub class or the control file will perform that job.

Alas, based on my experience and research, Velocity is a bit limited in
helping you with this problem.  I don't see a way to indirectly invoke a
macro using another macro as the name, for example:
	#set($argList = "\$arg1 \$arg2")
	#set($macroName = 'someMacro')
m4 has a special macro for doing this called indir.

Probably the best solution is to create a set of generic macros that must be
defined for each company.  Then use the velocimacro.library property to load
the appropriate company's macros.  Think of it like a dll that you will be
loaded at parse time.  But now the question is, how are you going to set
velocimacro.library property?

Velocity doesn't seem to have any log4j-like way of specifying its entire
configuration externally.  There is a default configuration located at
org/apache/velocity/runtime/default/velocity.defaults for which you could
insert your desired configuration ahead of in the classpath.

Another option is to figure out a way to provide properties to VPP.  To that
end, I enabled VPPFilter to pass its <param>s  of type 'velocity' onto its
VelocityEngine.  I enabled VPP and VPPJavac to specify velocity properties
using a <velocityproperty>.  Examples:

    <target name="vppjavac" depends="defineTasks">
        <vppjavac preprocess="true" prepdir="output" destdir="output"
            <classpath refid="vppPath" />
            <velocityProperty key="runtime.log" value="vpp.log"/>

    <target name="vppfilter" depends="defineTasks">
        <copy todir="output" overwrite="true">
            <fileset dir="src">
                <include name="**/*.html.vpp"/>
                <filterreader classname="foundrylogic.vpp.VPPFilter">
                    <classpath refid="vppPath"/>
                    <param type="velocity" name="runtime.log"
            <mapper type="glob" from="*.html.vpp" to="*.html"/>

These examples simply change the default runtime.log name to vpp.log rather
than velocity.log.  So, now you can specify any velocity properties,
including velocimacro.library, in your build.xml file.

Get the 1.1.0 version from


> -----Original Message-----
> From: M. Sean Gilligan []
> Sent: Tuesday, December 17, 2002 7:28 PM
> To: Velocity Users List
> Cc: Velocity Users List
> Subject: a PP for Velocity (Was RE: CPP like interface to Velocity)
> Didge, et. al,
> This looks like a great tool.  However, I was wondering if it
> could be used to preprocess Velocity templates?  At one point, I
> had considered attempting this with Texen, but it is hard
> (impossible?) to pre-process a file with a preprocessor that uses
> the same language.
> We are using one large set of .vm HTML templates for a large
> webapp that has several closely related "flavors".  We currently
> handle the different "flavors" with run-time conditionals, but
> build-time conditionals would increase performance.  Also since
> one "flavor" of our webapp may have one customer's proprietary
> information, it would be nice to have these conditionals execute
> at build-time.
> It's not an urgent need, but given the current discussion, I
> thought it would be worth asking.  Does anyone have any ideas?
> Thanks,
> Sean
> At 6:05 PM -0800 12/17/02, didge wrote:
> >Folks,
> >
> >I've created a new sourceforge project for my preprocessor code.
>  Check it
> >out at  I appreciate any and all constructive
> >feedback!  The source is included with the download.
> >
> >didge
> >
> --
> ------------------------------------------------------------------
> ---------
> M. Sean Gilligan                    :
> Catalla Systems, Inc.               : 831-439-9568 x11
> ------------------------------------------------------------------
> ---------
> --
> To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message