I have VTL 1.4 like:
#if(${passedvalue}=="1")
#set($column="A")
#elseif(${passedvalue}=="2")
#set($column="B")
#elseif(${passedvalue}=="3")
#set($column="C")
#set($column2="D")
#elseif(${passedvalue}=="4")
#set($column="E")
#set($column2="F")
#set($column3="G")
#end
I want $column, $column2 and $column2 available in a number of templates, so
am trying to avoid repeaing this code across templates.
Including the above in VM_common_references.vm in the same directory as all
my templates I try a
#parse("VM_common_references.vm")
but get "can not find query template". I have read mention of TEMPLATE_ROOT
but http://velocity.apache.org/engine/releases/velocity-1.4/user-guide.htmldoes
not mention where to define it....
Currently my setp includes a velocimacro.library common template:
public void applicationStartup() throws Exception {
props.setProperty("velocimacro.library", "VM_macros.vm");
props.setProperty("resource.loader", "class");
props.setProperty("class.resource.loader.description", "Classpath
Loader");
props.setProperty("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Velocity.init(props);
}
Using a parse means I would have to repeat the name of the common references
file for each use - or put it in a constant. It would be nice if it could be
done via a property perhaps...
Any advice appreciated.
Cheers,
Tom.