Oh, and if you were using Velocity 1.6.1, then you could use #parse to load your macros. But that will not work with earlier versions.
On Mon, Jan 5, 2009 at 2:19 PM, Nathan Bubna <[email protected]> wrote: > Your properties look fine and the logs confirm that. I can only guess > that whatever VelocityEngine or Velocity singleton that is processing > your template is not the same one that you are initializing. What > code/servlet/whatever are you using to process templates? Your > example code shows that you are using the Velocity singleton. Are you > using that to load and merge your templates? > > On Mon, Jan 5, 2009 at 2:09 PM, Alessandro Novarini > <[email protected]> wrote: >> Just a couple of infos to add... >> Velocity version is 1.4 >> My velocity.properties (apt-velocity.properties as stated in my previous >> mail) looks like this one: >> >> resource.loader=class >> >> class.resource.loader.description=Velocity Classpath Resource Loader >> >> class.resource.loader.class= >> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader >> >> >> velocimacro.permissions.allow.inline = true >> >> velocimacro.library.autoreload = true >> >> velocimacro.permissions.allow.inline.to.replace.global = true >> >> velocimacro.permissions.allow.inline.local.scope = true >> >> velocimacro.library=templates/action/apt/macros.vm >> >> >> runtime.log.error.stacktrace = true >> >> runtime.log.warn.stacktrace = true >> >> runtime.log.info.stacktrace = true >> >> runtime.log.debug.stacktrace = true >> >> runtime.log.invalid.reference = true >> >> >> >> Again, Thank You >> Ale >> >> On Mon, Jan 5, 2009 at 3:45 PM, Alessandro Novarini < >> [email protected]> wrote: >> >>> 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 >>> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
