Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

HTML::Template <TMPL_IF> 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.

Comment on HTML::Template <TMPL_IF> blocks
Select or Download Code
Replies are listed 'Best First'.
Re: HTML::Template <TMPL_IF> blocks
by ww (Bishop) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2015-07-31 10:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls