Re: Test variable for falsiness without generating a warning
Greg Huber <[email protected]> Wed, 6 Jan 2021 08:08:21 +0000
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
I would do this ##set($value=true) #if($value && true == $value) do stuff #elseif(!$value || false == $value) do other stuff #end On 05/01/2021 15:40, Christopher Schultz wrote: > All, > > I've got a template where a variable may be either undefined or false > (or other values) and I'm specifically trying to determine if it's > *false*. My template code looks like this: > > #if($value && true == $value) > do stuff > #elseif(false == $value) > do other stuff > #end > > I don't seem to be able to get rid of the warning in the log file if > $value is actually null. > > Is it possible? Typically, you'd do something like: > > > #if($value) > stuff when value is defined and/or truthy > #else > stuff when value is undefined and/or falsey > #end > > But I'm interested in telling the difference between (boolean) false > and 'undefined'. > > Any ideas? Or should I just live with the log message? In production, > these things don't generate logs, but in development they do. I'd just > like to reduce the noise in dev if possible. > > -chris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] >