You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Kevin Baynes <kb...@seagullsw.com> on 2003/02/11 23:26:28 UTC
Formal Notation
I was trying to write a URL to an image in HTML, using a simple #if #else
statement to choose which image.
I wrote it like so :
/path/to/image/#if($group.Sort ==
1)tri_down_black.gif#elsetri_down_gray.gif#end
When the else condition was true Velocity printed
"/path/to/image#elsetri_down_gray.gif"
Putting a space after the #else, prints "/path/to/image/ tri_down_gray.gif"
(broken URL).
The shortest workaround I found is:
#set($downgray = "tri_down_gray.gif")
/path/to/image/#if($group.Sort == 1)tri_down_black.gif#else$downgray#end
The Point :
It sure would be nice to have some formal notation :
#if(condition)#else{do something}#end
I've been around for the previous formal notation discussions (so no need to
update me), but I've not given up hope. ;-)
Thanks,
~akb
-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
Sent: Tuesday, February 11, 2003 3:11 PM
To: Velocity Users List
Subject: Re: path problem of servlet application
On Monday, February 10, 2003, at 12:55 AM, wu qi wrote:
>
>
> "Geir Magnusson Jr." <ge...@adeptra.com> wrote:
> This will depend on quite a few things, such as where you placed
> sample.vm, how you configured velocity, etc.
>
> Can you make the servlet example work?
>
> geir
>
> Yes the example can work! I put sample.vm just under $webapp
> direcotry,and did not configure the velocity for templates path,so I
> think it will treat the default path $webapp as the templates path.I
> try to put a.vm under every possible subdirectory,and the result is
> the same.
There are a few ways to get Velocity to load your templates. The file
resource loader is problematic to configure sometimes if you aren't
exactly aware of what's going on. What can be easier is using the
WebappResourceLoader found in the velocity-tools project.
I guess we should move this into the main tree and update the examples
for servlets.
geir
--
Geir Magnusson Jr 203-956-2604(w)
Adeptra, Inc. 203-247-1713(m)
geirm@adeptra.com
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Formal Notation
Posted by Peter Lammich <la...@ls5.cs.uni-dortmund.de>.
Have you already tried
/path/to/image/#if($group.Sort ==
1)tri_down_black.gif#else#**#tri_down_gray.gif#end
I also would appreciate some clean notation for that issue.
Peter
Kevin Baynes wrote:
> I was trying to write a URL to an image in HTML, using a simple #if #else
> statement to choose which image.
> I wrote it like so :
>
> /path/to/image/#if($group.Sort ==
> 1)tri_down_black.gif#elsetri_down_gray.gif#end
>
> When the else condition was true Velocity printed
> "/path/to/image#elsetri_down_gray.gif"
>
> Putting a space after the #else, prints "/path/to/image/ tri_down_gray.gif"
> (broken URL).
>
> The shortest workaround I found is:
>
> #set($downgray = "tri_down_gray.gif")
> /path/to/image/#if($group.Sort == 1)tri_down_black.gif#else$downgray#end
>
> The Point :
> It sure would be nice to have some formal notation :
> #if(condition)#else{do something}#end
>
> I've been around for the previous formal notation discussions (so no need to
> update me), but I've not given up hope. ;-)
>
> Thanks,
>
> ~akb
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
> Sent: Tuesday, February 11, 2003 3:11 PM
> To: Velocity Users List
> Subject: Re: path problem of servlet application
>
> On Monday, February 10, 2003, at 12:55 AM, wu qi wrote:
>
> >
> >
> > "Geir Magnusson Jr." <ge...@adeptra.com> wrote:
> > This will depend on quite a few things, such as where you placed
> > sample.vm, how you configured velocity, etc.
> >
> > Can you make the servlet example work?
> >
> > geir
> >
> > Yes the example can work! I put sample.vm just under $webapp
> > direcotry,and did not configure the velocity for templates path,so I
> > think it will treat the default path $webapp as the templates path.I
> > try to put a.vm under every possible subdirectory,and the result is
> > the same.
>
> There are a few ways to get Velocity to load your templates. The file
> resource loader is problematic to configure sometimes if you aren't
> exactly aware of what's going on. What can be easier is using the
> WebappResourceLoader found in the velocity-tools project.
>
> I guess we should move this into the main tree and update the examples
> for servlets.
>
> geir
>
> --
> Geir Magnusson Jr 203-956-2604(w)
> Adeptra, Inc. 203-247-1713(m)
> geirm@adeptra.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org