Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Template Toolkit example getting blank output page

by Anonymous Monk
on Sep 24, 2012 at 10:38 UTC ( #995346=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:


I have tried below example using Template toolkit, but display page is getting blank.
header.html, footer.html and main.html are kept under /home/userone/public_html/template directory.
Can anyone tell me why I am getting blank page when I call script.
Operating System : Linux
Perl Version : 5.10.1
Apache version 2.2.22

header.html <html> <head> <title>[% title %]</title> </head> <body bgcolor="#ffffff"> <h1>[% title %]</h1> *********************************************** footer.html <div align="center"> [% copyright %] </div> </body> </html> *************************************************** main.html [% PROCESS header title="Some Interesting Links" %] <p> Here are some interesting links: <ul> [% FOREACH link = weblinks %] <li><a href="[% link.url %]">[% link.title %]</a></li> [% END %] </ul> </p> [% PROCESS footer %] *************************************************** #!/usr/bin/perl print "Content-Type: text/html\n\n"; use strict; use warnings; use Template; # create template processor my $tt = Template->new({ INCLUDE_PATH => [ '/home/userone/public_html/template', ], PRE_PROCESS => 'header', POST_PROCESS => 'footer', }); # define data my $data = { copyright => '&copy; 2002 Andy Wardley', weblinks => [ { url => '', title => 'Apache/mod_perl', }, { url => '', title => 'template Toolkit', }, ] }; $tt->process('main.html',$data) || die $tt->error(); ********************************

could you please help me to get an output page


Replies are listed 'Best First'.
Re: Template Toolkit example getting blank output page
by marto (Archbishop) on Sep 24, 2012 at 10:57 UTC

    See the various examples in the Template documentation for the Process method. You need to define how you'd like it to output. For example:

    my $output=''; $tt->process('main.html',$data, \$output) || die $tt->error(); print $output;
Re: Template Toolkit example getting blank output page
by grumbert (Scribe) on Sep 24, 2012 at 10:59 UTC

    Without looking at your TT code, it may be worth looking at your apache error & httpd logs. Typically errors get put in either of those logs and may provide valuable information on troubleshooting.

    Sorry if this is all rather obvious but it would be my first step in figuring out what's happening.

Re: Template Toolkit example getting blank output page
by sundialsvc4 (Abbot) on Sep 24, 2012 at 12:59 UTC

    Use a client-side debugger such as Firebug, or the various developer-tools built into most browsers, to LQQK at the HTML code that your application is actually sending.   Only in this way will you actually know.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://995346]
Approved by marto
[shmem]: LanX: you can pass a shell command via @ARGV.
[shmem]: moritz: don't know, but you'd prolly whip it up in no time.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2018-05-21 13:19 GMT
Find Nodes?
    Voting Booth?