[prev in list] [next in list] [prev in thread] [next in thread]
List: velocity-user
Subject: Re: Global references and parse file location
From: boardtc <boardtc () gmail ! com>
Date: 2010-05-28 8:58:33
Message-ID: AANLkTimgyCnozuDx52ZAtQkowUXE3cXO8trycse9DS9l () mail ! gmail ! com
[Download RAW message or body]
Clearly I need to do some more reading...but where?
http://velocity.apache.org/engine/devel/developer-guide.html only says in
relation to #parse, "this may be used to make all includes relative to the
current directory". Where is the current directory set for Velocity? I got a
hold of Pro Jakarta Velocity (2004) but #parse was not mentioned.
Cheers,
Tom.
On 26 May 2010 15:11, boardtc <boardtc@gmail.com> wrote:
> 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.
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic