Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

HTML::Template Isn't Working

by rjahrman (Scribe)
on Aug 05, 2004 at 23:46 UTC ( [id://380414]=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying to use HTML::Template in my script. I have wdi.tmpl in the same folder as my script, and I use these lines:

my $template = HTML::Template->new(filename => 'wdi.tmpl'); # Later... $template->param(DIRLINKS => "1"); $template->param(CONTENT => "2"); # At the end... $template->output();

However, no matter what I do I only get a blank page. I viewed the source and it looks like it's just a standard 'blank page' line. What am I doing wrong?

Edited by davido: Added code tags and fixed HTML.

Replies are listed 'Best First'.
Re: HTML::Template Isn't Working
by dws (Chancellor) on Aug 06, 2004 at 00:01 UTC
    I viewed the source and it looks like it's just a standard 'blank page' line. What am I doing wrong?

    Try

    print $template->output();

    Also, you'll need to ensure that you print a valid HTTP response header first.

    print "Content-type: text/html\n\n";

    will do.

Re: HTML::Template Isn't Working
by gryphon (Abbot) on Aug 06, 2004 at 01:22 UTC

    Greetings rjahrman,

    To follow-up on what dws wrote, yes, you want to use print for the output if you're using HTML::Template alone. If you're using H::T along with something like CGI::Application, you may (depending on WWYWTDI) want to return the output instead of print.

    Good luck.

    gryphon
    code('Perl') || die;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found