stevieb has asked for the wisdom of the Perl Monks concerning the following question:

I am having a brain fart and old-timer moment. I'm tired and not seeing something obvious...

Can I get a Monk to help me figure out how to check for truth when presenting an element with HTML::Template?

I have the following code which essentially sets a done flag to true or false:

... my $unfinished_bcasts = $Broadcast->unfinished; my $finished = 0; if (! grep { $bcast_id == $_ } @$unfinished_bcasts) { $finished = 1; } $bcast_data->{$bcast_id}{finished} = $finished; ...

I then have an HTML::Template template that has this:

<TMPL_IF NAME=FINISHED> <tr align="left"> <td><b>Time Finished</b></td> <td><TMPL_VAR NAME=TIME_FINISHED></td> </tr> </TMPL_IF>

My expectation is, is that the TIME_FINISHED var will appear in the HTML table *if* the FINISHED var is true. My issue is that no matter what I set FINISHED to, the TIME_FINISHED always appears in the HTML. I can confirm with certainty that both variables are being passed along properly to the template.

Please help me with what I'm completely missing.

-stevieb

Replies are listed 'Best First'.
Re: Check for truth of variable in HTML::Template
by GrandFather (Saint) on Jul 17, 2024 at 06:51 UTC

    The fine documentation suggests you need to call $template->param(FINISHED => $finished).

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re: Check for truth of variable in HTML::Template
by stevieb (Canon) on Jul 17, 2024 at 06:06 UTC

    This may be my own fsck up here... please don't waste time on looking into it, as I believe I'm not actually sending the proper data to the template engine... I'll advise if this is still a problem after I confirm my data.