Test variable for falsiness without generating a warning
Christopher Schultz <[email protected]> Tue, 5 Jan 2021 10:40:06 -0500
| Newsgroups | gmane.comp.jakarta.velocity.user |
|---|---|
| Message-ID | <[email protected]> |
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