velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr. <ge...@adeptra.com>
Subject Re: a PP for Velocity (Was RE: CPP like interface to Velocity)
Date Wed, 18 Dec 2002 12:02:03 GMT

On Wednesday, December 18, 2002, at 06:05 AM, didge wrote:

> 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')
> 	#$macroName($argList)
> m4 has a special macro for doing this called indir.

<popping_in_quickly>

You could make a little tool that does an eval(), and then do

#set($thingy = '#someMacro( $arg1 $arg2 )")
$tool.eval($thingy)

</popping_in_quickly>

>
> 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"
> srcdir="src">
>             <classpath refid="vppPath" />
>             <velocityProperty key="runtime.log" value="vpp.log"/>
>         </vppjavac>
>     </target>
>
>     <target name="vppfilter" depends="defineTasks">
>         <copy todir="output" overwrite="true">
>             <fileset dir="src">
>                 <include name="**/*.html.vpp"/>
>             </fileset>
>             <filterchain>
>                 <filterreader classname="foundrylogic.vpp.VPPFilter">
>                     <classpath refid="vppPath"/>
>                     <param type="velocity" name="runtime.log"
> value="vpp.log"/>
>                 </filterreader>
>             </filterchain>
>             <mapper type="glob" from="*.html.vpp" to="*.html"/>
>         </copy>
>     </target>
>
> 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 http://vpp.sourceforge.net.
>
> didge
>
>
>> -----Original Message-----
>> From: M. Sean Gilligan [mailto:Sean_Gilligan@catalla.com]
>> 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 http://vpp.sourceforge.net.  I appreciate any and all 
>>> constructive
>>> feedback!  The source is included with the download.
>>>
>>> didge
>>>
>>
>>
>> --
>> ------------------------------------------------------------------
>> ---------
>> M. Sean Gilligan                    : mailto:Sean_Gilligan@catalla.com
>> Catalla Systems, Inc.               : 831-439-9568 x11
>> ------------------------------------------------------------------
>> ---------
>>
>> --
>> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:   
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:velocity-user-help@jakarta.apache.org>
>
>
-- 
Geir Magnusson Jr                                   203-355-2219(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.com


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message