|
From: McDonald, B. <Bru...@ba...> - 2003-10-09 15:57:13
|
The babeldoc user env variable is guaranteed to be there (except in web containers maybe)
This looks like a great patch.
-----Original Message-----
From: David Kinnvall [mailto:dav...@al...]
Sent: Thursday, October 09, 2003 11:52 AM
To: bab...@li...
Subject: [Babeldoc-devel] Enable file-based inclusion of Velocity
templates?
Hi people,
When mucking around with Velocity templates for sending mails
to various people depending on the results of pipeline stages,
I found it much easier to work with template files stored in
the filesystem, in and below the current working directory, in
which my Babeldoc configuration lives.
In a stage config, you can then do:
<foo>.smtpMessage=#parse("templates/mailtemplate.vm")
and have the body of mailtemplate.vm evaluated in the context
of the pipeline stage, while being included from the filesystem
in the templates directory, right next to your pipeline dir, or
even in it, for that matter.
Due to Velocity's template reloading (and caching) you can even
update the template(s) and have Velocity reload them without
having to restart Babeldoc.
Patch (to VariableProcessor only) as follows:
Index: com/babeldoc/core/VariableProcessor.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/VariableProcessor.java,v
retrieving revision 1.8
diff -u -r1.8 VariableProcessor.java
--- com/babeldoc/core/VariableProcessor.java 7 Aug 2003 21:12:25 -0000 1.8
+++ com/babeldoc/core/VariableProcessor.java 9 Oct 2003 15:43:23 -0000
@@ -97,9 +97,12 @@
/**
* Setup up the velocity upfront
*/
- Velocity.setProperty("resource.loader", "classpath");
+ Velocity.setProperty("resource.loader", "file,classpath");
Velocity.setProperty("classpath.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ Velocity.setProperty("file.resource.loader.class",
+ "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
+ Velocity.setProperty("file.resource.loader.path", ".");
Velocity.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
Velocity.setProperty("runtime.log.logsystem.log4j.category", "babeldoc");
Note that the FileResourceLoader is used in conjunction with the
original ClasspathResourceLoader, which enables you to:
1. Use Babeldoc exactly as before, with templates in the core
.jar-files.
2. Use filesystem-based templates at will.
3. Override Babeldoc's internal templates with templates in the
filesystem, as long as their path-names are equal. Neat?
Comments?
One thing that strikes me right now is that perhaps the path for
the FileResourceLoader should not be ".", but rather connected to
the BABELDOC_USER directory, or similar. Is that guaranteed to be
present in a property by itself?
/David
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Babeldoc-devel mailing list
Bab...@li...
https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|