HTML::template Module in perl

A

andy

I have a html file named test.tmpl and containing the below lines.
=====================================================================
<html>
<head>
<title>Song Listing</title>
</head>
<body>
<h1>My Songs</h1>

<tr>

<td valign="top">
<table width="150%" border="1" cellpadding="3"
cellspacing="1">
<tr height="20" style="font-size: 95%;"><td>&nbsp;</td></tr>

<tr height="20" style="font-size: 95%;"><td align="left"
valign="middle"><a href="TMPL_VAR NAME=SOME_DATA">NITIN</a></td></tr>

</table>
</td>

<table>
</BODY>
</HTML>
=====================================================================
I have a cgi script as below to open this tmpl file from the web
browser.
The cgi script is mentioned as below.
======================================================================
#!/usr/bin/perl -w
use strict;
use lib "site/lib/perl5/5.8.5/";
use lib "site/lib/perl5/5.8.5/i386-linux-thread-multi/";
use lib "site/lib/perl5/site_perl/5.8.5/";
use lib "site/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/";
use CGI::pretty qw/:standard/;
use CGI;
use CGI::Session;
use HTML::Template;
my $site = "http://www.google.co.in";
my $cgi = new CGI;
print $cgi->header();
my $template = HTML::Template->new(filename => "//usr//local//apache2/
templates//test.tmpl");
$template->param(SOME_DATA=> $site);
print $template->output;
1;
======================================================================
My requirement is to link some other page like http://www.google.co.in
to the link in the main page "NITIN" AND i WANT TO USE HTML::TEMPLATE
FOR THIS BECAUSE I WILL BE LINKING A LOT OF THINGS IN THE SAME LINK IN
FUTURE.

But while running the script in the command line getting a error like
"
Content-Type: text/html; charset=ISO-8859-1

HTML::Template : Attempt to set nonexistent parameter 'some_data' -
this parameter name doesn't match any declarations in the template
file : (die_on_bad_params => 1) at 123.pl line 15
"

Can any body suggest me how to do this dynamic linking using
html::template module.

Or what is the eror in the script. where exactly the variable in
the .tmpl file is to be mentioned so that it will work.

regards
Nitin
 
X

Xicheng Jia

I have a html file named test.tmpl and containing the below lines.
=====================================================================
<html>
<head>
<title>Song Listing</title>
</head>
<body>
<h1>My Songs</h1>

<tr>

<td valign="top">
<table width="150%" border="1" cellpadding="3"
cellspacing="1">
<tr height="20" style="font-size: 95%;"><td>&nbsp;</td></tr>

<tr height="20" style="font-size: 95%;"><td align="left"
valign="middle"><a href="TMPL_VAR NAME=SOME_DATA">NITIN</a></td></tr>

change to:

<a href="<TMPL_VAR NAME=SOME_DATA>">NITIN</a>


Regards,
Xicheng
 
J

J. Gleixner

Xicheng said:
I have a html file named test.tmpl and containing the below lines.
===================================================================== [...]
<tr height="20" style="font-size: 95%;"><td align="left"
valign="middle"><a href="TMPL_VAR NAME=SOME_DATA">NITIN</a></td></tr>

change to:

<a href="<TMPL_VAR NAME=SOME_DATA>">NITIN</a>
my $template = HTML::Template->new(filename
=>"//usr//local//apache2/templates//test.tmpl");

And, why the double '/' in the path?
 
A

andy

Thanks a lot.



Xicheng said:
I have a html file named test.tmpl and containing the below lines.
===================================================================== [...]
<tr height="20" style="font-size: 95%;"><td align="left"
valign="middle"><a href="TMPL_VAR NAME=SOME_DATA">NITIN</a></td></tr>
change to:
<a href="<TMPL_VAR NAME=SOME_DATA>">NITIN</a>
=>"//usr//local//apache2/templates//test.tmpl");

And, why the double '/' in the path?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top