velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alessandro Novarini" <a.novar...@sourcesense.com>
Subject How to load a macro from file (again!!!)
Date Mon, 05 Jan 2009 14:45:52 GMT
Hi everybody,

I am new to this list, and I need your help.
I've already looked for some tips but I'm still a bit puzzled about this
issue: how to load a velocity macro file.
I know this topic has been discussed for a long time and I think I've search
back and forth enough, there's just a small step to do that's still missing.

This is the environment: Developing a plugin for Jira in Tomcat.
This is out piece of code Java Side:
-------
        Properties customVelocityFile = new Properties();
        InputStream resourceAsStream =
this.getClass().getClassLoader().getResourceAsStream("apt-velocity.properties");
        customVelocityFile.load(resourceAsStream);
        Velocity.init(customVelocityFile);
-------

So that I can load my vmfile from classpath. This is actually working, as I
can see from velocity.log file:
-------
2009-01-05 15:25:37,955 - Velocimacro : initialization starting.
2009-01-05 15:25:37,955 - Velocimacro : adding VMs from VM library template
: templates/action/apt/macros.vm
2009-01-05 15:25:37,956 - Velocimacro : added new VM : #descriptionDivItem(
issue ) : source = templates/action/apt/macros.vm
2009-01-05 15:25:37,956 - ResourceManager : found
templates/action/apt/macros.vm with loader
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
2009-01-05 15:25:37,956 - Velocimacro :  VM library template macro
registration complete.
2009-01-05 15:25:37,956 - Velocimacro : allowInline = true : VMs can be
defined inline in templates
2009-01-05 15:25:37,956 - Velocimacro : allowInlineToOverride = true : VMs
defined inline may replace previous VM definitions
2009-01-05 15:25:37,956 - Velocimacro : allowInlineLocal = true : VMs
defined inline will be local to their defining template only.
2009-01-05 15:25:37,956 - Velocimacro : messages on  : VM system will output
logging messages
2009-01-05 15:25:37,956 - Velocimacro : autoload on  : VM system will
automatically reload global library macros
2009-01-05 15:25:37,956 - Velocimacro : initialization complete.
2009-01-05 15:25:37,956 - Velocity successfully started.
-------

In the lines above you can read that the file loaded is
templates/action/apt/macros.vm and it contains the macro
#descriptionDivItem( issue )

After that I tried to call this macro from a velocity template, but the
macro wasn't parsed. Notice that I didn't use the #parse directive, maybe
should I use it?
I think I'm near to the final solution, but at the moment I'm clueless.

I hope I have been clear enough, and that you can give me some advice.

Thank you in advance.

Happy new year
Ale

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message