Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Check for truth of variable in HTML::Template

by stevieb (Canon)
on Jul 17, 2024 at 05:55 UTC ( [id://11160654]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11160654]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-09-08 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.