|
From: David K. <dav...@al...> - 2003-10-10 08:57:23
|
Ok, I have reworked the patch slightly, as follows.
Purpose: Allow Velocity templates to be loaded from
the filesystem in addition to the classpath.
Changes (to VariableProcessor only):
- Add the FileResourceLoader to be used before the
default ClasspathResourceLoader
- Load templates from the filesystem using the set
of search paths provided by the EnvironmentLoader
(Path for Velocity constructed as CSV, using the
imported StringUtils.join method)
- Enable caching of loaded templates with a check
for modifications every two seconds
Consequences:
- Templates for use within Babeldoc can now be placed
and managed in the filesystem external to any jar-files
- Templates in the filesystem override templates in
Babeldoc .jar-files having the same name
- It is now very easy to use large, complex templates
in pipeline stages, since all that's needed is:
<stage-name>.<whatever>=#parse("path/to/template.vm")
where the template.vm is evaluated in context of the
pipeline stage and it's document just as an inline
template directly specified in the property would be
Note: it is also possible to do this:
<stage-name>.<whatever>=#include("path/to/something")
which includes something verbatim but does NOT cause
Velocity to actually evaluate it as a template, at
least according to the Velocity docs
- The #parse and #include statements should also be
possible to use inline (#parse recursively) inside
template bodies in general, but I have not tested
this yet (should work, though, since the default
parse-depth of Velocity is set to 10)
- It is now possible to edit a template file and have
the new version of it used without restarting Babeldoc,
due to the reloading mechanism of Velocity
I have tested these changes in my setup with no ill
effects that I have been able to see, in pipelines
that use template files and pipelines that do not,
but please test it further, since it's a change in
the very core of Babeldoc, which makes me nervous.
Patch attached, for your consideration.
Regards,
David Kinnvall
|