Hi Nathan,
Do you have any log output for this that we could see?
Yes, attached below. I've tracked the problem down to a difference in
the way I'm invoking the engine. I have two test cases, both of which
read the same template. This one, taken from the user manual, works fine:
VelocityEngine ve = new VelocityEngine();
ve.init();
VelocityContext context = new VelocityContext();
Template template = null;
template = ve.getTemplate(templateName);
StringWriter sw = new StringWriter();
template.merge( context, sw );
log.debug( sw.toString() );
This one, which I use because my templates will in future be dynamically
generated rather than loaded from a file, doesn't:
StringWriter sw = new StringWriter();
java.io.File f = new java.io.File( templateName );
Reader reader = new FileReader( f );
VelocityEngine ve = new VelocityEngine();
ve.init();
log.debug( "Velocity macro prop: " + ve.getProperty(
"velocimacro.permissions.allow.inline" ));
VelocityContext pvc = new VelocityContext();
ve.evaluate( pvc, sw, null, reader );
log.debug( sw.toString() );
I can't see a way of creating a Template object from a reader, so from
reading the API I think I have to call evaluate() directly. However, I
must presumably be missing a crucial step somewhere.
Any suggestions gratefully received.
Thanks,
Ian
__________________________________________________________________
Ian Dickinson HP Labs, Bristol, UK mailto:[EMAIL PROTECTED]
http://www.hpl.hp.com/people/Ian_Dickinson ph: +44 117 312 8796
Hewlett-Packard Limited Registered No: 690597 England
Registered Office: Cain Road, Bracknell, Berks RG12 1HN
Thu Aug 09 15:33:55 BST 2007 [debug] AvalonLogChute initialized using file
'velocity.log'
Thu Aug 09 15:33:55 BST 2007 [trace]
*******************************************************************
Thu Aug 09 15:33:55 BST 2007 [debug] Starting Apache Velocity v1.5 (compiled:
2007-02-22 08:52:29)
Thu Aug 09 15:33:55 BST 2007 [trace] RuntimeInstance initializing.
Thu Aug 09 15:33:55 BST 2007 [debug] Default Properties File:
org/apache/velocity/runtime/defaults/velocity.properties
Thu Aug 09 15:33:55 BST 2007 [debug] Trying to use logger class
org.apache.velocity.runtime.log.AvalonLogChute
Thu Aug 09 15:33:55 BST 2007 [debug] Using logger class
org.apache.velocity.runtime.log.AvalonLogChute
Thu Aug 09 15:33:55 BST 2007 [debug] Default ResourceManager initializing.
(class org.apache.velocity.runtime.resource.ResourceManagerImpl)
Thu Aug 09 15:33:55 BST 2007 [debug] ResourceLoader instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Thu Aug 09 15:33:55 BST 2007 [trace] FileResourceLoader : initialization
starting.
Thu Aug 09 15:33:55 BST 2007 [debug] Do unicode file recognition: false
Thu Aug 09 15:33:55 BST 2007 [info] FileResourceLoader : adding path '.'
Thu Aug 09 15:33:55 BST 2007 [trace] FileResourceLoader : initialization
complete.
Thu Aug 09 15:33:55 BST 2007 [debug] ResourceCache: initialized (class
org.apache.velocity.runtime.resource.ResourceCacheImpl)
Thu Aug 09 15:33:55 BST 2007 [trace] Default ResourceManager initialization
complete.
Thu Aug 09 15:33:55 BST 2007 [debug] Loaded System Directive:
org.apache.velocity.runtime.directive.Literal
Thu Aug 09 15:33:55 BST 2007 [debug] Loaded System Directive:
org.apache.velocity.runtime.directive.Macro
Thu Aug 09 15:33:55 BST 2007 [debug] Loaded System Directive:
org.apache.velocity.runtime.directive.Parse
Thu Aug 09 15:33:55 BST 2007 [debug] Loaded System Directive:
org.apache.velocity.runtime.directive.Include
Thu Aug 09 15:33:55 BST 2007 [debug] Loaded System Directive:
org.apache.velocity.runtime.directive.Foreach
Thu Aug 09 15:33:56 BST 2007 [debug] Created '20' parsers.
Thu Aug 09 15:33:56 BST 2007 [trace] Velocimacro : initialization starting.
Thu Aug 09 15:33:56 BST 2007 [debug] Velocimacro : "velocimacro.library" is
not set. Trying default library: VM_global_library.vm
Thu Aug 09 15:33:56 BST 2007 [debug] Velocimacro : Default library not found.
Thu Aug 09 15:33:56 BST 2007 [debug] Velocimacro : allowInline = true : VMs
can be defined inline in templates
Thu Aug 09 15:33:56 BST 2007 [debug] Velocimacro : allowInlineToOverride =
false : VMs defined inline may NOT replace previous VM definitions
Thu Aug 09 15:33:56 BST 2007 [debug] Velocimacro : allowInlineLocal = false :
VMs defined inline will be global in scope if allowed.
Thu Aug 09 15:33:56 BST 2007 [debug] Velocimacro : autoload off : VM system
will not automatically reload global library macros
Thu Aug 09 15:33:56 BST 2007 [trace] Velocimacro : Velocimacro :
initialization complete.
Thu Aug 09 15:33:56 BST 2007 [trace] RuntimeInstance successfully initialized.
Thu Aug 09 15:33:56 BST 2007 [warn] Velocimacro : VM addition rejected :
programmer error : arg null
Thu Aug 09 15:33:56 BST 2007 [warn] Failed to add macro: #ijd( ) : source =
null
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]