You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "M. Tinnemeyer" <ma...@gmx.net> on 2009/05/13 19:31:17 UTC

Escaping EL in JSTL

Good evening,

I use Velocity to generate several Jsp pages. This works quite well as  
long as I do not use EL expressions like:

<c:forEach items="${foo != null}" var="bar">
  ...
</c:forEach>

I tried to escape the $ sign by using a backslash or but then Velocity  
stumbles upon "!=".
#set( $D = '$' ) like stated in the user-guide did not improve the  
situation.

Does anybody have a clue on this ?

Maybe there is a way to exclude a whole line from being parsed by  
Velocity ?

Kind regards
Marc Tinnemeyer

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Escaping EL in JSTL

Posted by "M. Tinnemeyer" <ma...@gmx.net>.
Thank's a lot. I guess I misinterpreted the example in the user-guide.

#set ( $D = '$' )
<c:if test=${D}{ foo != null }">

does the trick. (the curly braces seem to be important)


On May 13, 2009, at 8:17 PM, Nathan Bubna wrote:

> In the upcoming 1.7, you'll be able to do
>
> #[[<c:if test="${ foo != null }">]]#
>
> but for now, you have to use what we call "poor man's escaping":
>
> #set( $D = '$' )
> <c:if test="$D{ foo != null}">
>
> Of course, it's best if you can just set the $D reference globally in
> your context instead of every template. :)
>
> On Wed, May 13, 2009 at 10:41 AM, M. Tinnemeyer <ma...@gmx.net>  
> wrote:
>> Ups
>>
>> the code was:
>>
>> <c:if test="${ foo != null }">
>>  ...
>> </c:if>
>>
>>
>> On May 13, 2009, at 7:31 PM, M. Tinnemeyer wrote:
>>
>>> Good evening,
>>>
>>> I use Velocity to generate several Jsp pages. This works quite  
>>> well as
>>> long as I do not use EL expressions like:
>>>
>>> <c:forEach items="${foo != null}" var="bar">
>>> ...
>>> </c:forEach>
>>>
>>> I tried to escape the $ sign by using a backslash or but then  
>>> Velocity
>>> stumbles upon "!=".
>>> #set( $D = '$' ) like stated in the user-guide did not improve the
>>> situation.
>>>
>>> Does anybody have a clue on this ?
>>>
>>> Maybe there is a way to exclude a whole line from being parsed by  
>>> Velocity
>>> ?
>>>
>>> Kind regards
>>> Marc Tinnemeyer
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Escaping EL in JSTL

Posted by Nathan Bubna <nb...@gmail.com>.
In the upcoming 1.7, you'll be able to do

#[[<c:if test="${ foo != null }">]]#

but for now, you have to use what we call "poor man's escaping":

#set( $D = '$' )
<c:if test="$D{ foo != null}">

Of course, it's best if you can just set the $D reference globally in
your context instead of every template. :)

On Wed, May 13, 2009 at 10:41 AM, M. Tinnemeyer <ma...@gmx.net> wrote:
> Ups
>
> the code was:
>
> <c:if test="${ foo != null }">
>  ...
> </c:if>
>
>
> On May 13, 2009, at 7:31 PM, M. Tinnemeyer wrote:
>
>> Good evening,
>>
>> I use Velocity to generate several Jsp pages. This works quite well as
>> long as I do not use EL expressions like:
>>
>> <c:forEach items="${foo != null}" var="bar">
>> ...
>> </c:forEach>
>>
>> I tried to escape the $ sign by using a backslash or but then Velocity
>> stumbles upon "!=".
>> #set( $D = '$' ) like stated in the user-guide did not improve the
>> situation.
>>
>> Does anybody have a clue on this ?
>>
>> Maybe there is a way to exclude a whole line from being parsed by Velocity
>> ?
>>
>> Kind regards
>> Marc Tinnemeyer
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Escaping EL in JSTL

Posted by "M. Tinnemeyer" <ma...@gmx.net>.
Ups

the code was:

<c:if test="${ foo != null }">
   ...
</c:if>


On May 13, 2009, at 7:31 PM, M. Tinnemeyer wrote:

> Good evening,
>
> I use Velocity to generate several Jsp pages. This works quite well  
> as long as I do not use EL expressions like:
>
> <c:forEach items="${foo != null}" var="bar">
> ...
> </c:forEach>
>
> I tried to escape the $ sign by using a backslash or but then  
> Velocity stumbles upon "!=".
> #set( $D = '$' ) like stated in the user-guide did not improve the  
> situation.
>
> Does anybody have a clue on this ?
>
> Maybe there is a way to exclude a whole line from being parsed by  
> Velocity ?
>
> Kind regards
> Marc Tinnemeyer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org