In DTML, the statement
<dtml-if "varname == 'hello'">
will raise an exception if varname isn't defined, but
<dtml-if varname>
works fine; true if defined & true, false if not defined
or not true.
So, there's no need to "predeclare" variables just to use
them in dtml-if testing.
If you need to check something about a variable, and can't
be sure if its declared or not, you can use this:
<dtml-if "varname and varname == 'Hello'">
which will not raise an exception if varname is not declared.
BTW, if you work frequently w/variables that may or may not
exist, and want to set default values if they don't exist,
dtml-set (an add-in) is great. You can say things like:
<dtml-set varname="'Hello'" optional>
rather than the wordy
<dtml-unless varname>
<dtml-call "REQUEST.set('varname', 'Hello')">
</dtml-unless>
|