Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

HTML::Template blocks

by mydnight (Initiate)
on Aug 03, 2012 at 06:00 UTC ( #985158=perlquestion: print w/replies, xml ) Need Help??
mydnight has asked for the wisdom of the Perl Monks concerning the following question:

EDIT: I just noticed the typo in my TMPL_ELSE block, and now it's working... I think I either need more sleep or more caffeine.

I'm having trouble getting HTML::Template's blocks to function -- it seems like my template is just skipping that code entirely.

<TMPL_LOOP NAME=DATA> <TMPL_VAR NAME=complete><br> <TMPL_IF NAME="complete"> <!-- Some HTML here --> <TMPLE_ELSE> <!-- Some other HTML here --> </TMPL_IF> </TMPL_LOOP>
The <TMPL_VAR> line is displaying the expected values, but nothing in the block below it is showing up whatsoever. The data structure I'm passing in to the template is:
$VAR1 = [ { 'code' => 26, 'message' => 'Start building sensors for Jarvis', 'complete' => 0 }, { 'code' => 33, 'message' => 'Machine learning to determine if actions are app +ropriate or not', 'complete' => 0 }, { 'code' => 37, 'message' => 'Play by genre audioserv method', 'complete' => 0 } ];
Any help is greatly appreciated -- I've been banging my head against it for the last hour.

Replies are listed 'Best First'.
Re: HTML::Template <TMPL_IF> blocks
by ww (Archbishop) on Aug 03, 2012 at 07:47 UTC

      Perhaps more sleep would help; perhaps caffeine...

      Or perhaps warnings/lint for templates

Re: HTML::Template <TMPL_IF> blocks
by sundialsvc4 (Abbot) on Aug 03, 2012 at 13:45 UTC

    I started to quip, “better to use a better templating system!”   But of course you can’t realistically do that.   An “XML Lint” tool is certainly a good tool to have handy, because tpyos always come in piars.

    The “teddy bear technique” quote, linked-to in the above comment, says in part:   Talk your problems out with a silent but sympathetic listener and the answers will often spring full blown (or nearly so) as if from (someone’s) forehead.   Neglecting to further mention that a good slap on the aforesaid forehead ... Doh!!™ ... also is known to be very beneficial in such cases.   (Go ahead... click the hyperlink... enjoy.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://985158]
Approved by tobyink
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-09-22 19:52 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (268 votes). Check out past polls.