RE: [htmltmpl] TMPL_IF truth vs definition
Brought to you by:
samtregar
|
From: Tugrul G. <tu...@ga...> - 2002-06-21 16:19:34
|
> I don't really see why you can't take the pain and amend your CGI scripts.
> What documentation warnings are you referring to, that advise against this
> course of action? (I can see one warning against matching TMPL_IF to perl if
> statements, but that doesn't seem to apply.)
>
> Consider the H::T snippet,
> <TMPL_IF NAME="my_bool">...</TMPL_IF>
>
> In your CGI, instead of writing simply,
> { my_bool => $x }
>
> you would write something like this,
> { my_bool => defined $x }
>
I'm taking a short cut by never exporting a boolean. I'm working on the
model if the data exists, then include this HTML with the output. So if
the conditions are never met (say, a table of people matching a
criteria, but there happen to be none), I never set that variable, and
therefore I don't want the associated HTML out there.
Right now I'd have to stick in a bunch of extra lines to do my_var_bool
=> 1 wherever I have a my_var => $x in case if ($x) is false.
TMPL_IF works all of the time except when the data that exists just
happens to be 0 (or anything else that is false).
Tugrul Galatali
|