You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Li Xiaoli-a17351 <a1...@motorola.com> on 2001/06/05 04:29:02 UTC

Conditional not operator

Hi 

Can you tell me whether VTL support conditional not operator, such as !

I mean if  #foo = true, !(#foo) = false. Is that OK?

Thanks

Charley

Re: Conditional not operator

Posted by Christoph Reck <Ch...@dlr.de>.
If you spell it right - with the velocity syntax, then 
having a:
#set( $foo = true )

in the following usage

#if( $foo )
  \$foo evaluated to true.
#else
  \$foo evaluated to false.
#end

is the same as the logic-inverted:

#if( !$foo )
  \$foo evaluated to false.
#else
  \$foo evaluated to true.
#end

and will emit
  $foo evaluated to true.


Your questioned example was mixing the directive syntax (#) with
the reference syntax ($). As to my knowledge the not operator
is only valid within an #if-directive equation, and it will not 
work outside when redering, so:
  The foo reference is not !$foo
will render:
  The foo reference is not !true
And the '!' remains there untouched. So questioned example is
also missing something around it to make it work.

:) Christoph



Li Xiaoli-a17351 wrote:
> 
> Hi
> 
> Can you tell me whether VTL support conditional not operator, such as !
> 
> I mean if  #foo = true, !(#foo) = false. Is that OK?
> 
> Thanks
> 
> Charley