Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > HTML::template Module in perl

Reply
Thread Tools

HTML::template Module in perl

 
 
andy
Guest
Posts: n/a
 
      04-06-2007
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:retty 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

 
Reply With Quote
 
 
 
 
Xicheng Jia
Guest
Posts: n/a
 
      04-06-2007
On Apr 6, 4:26 am, "andy" <(E-Mail Removed)> wrote:
> 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


 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      04-06-2007
Xicheng Jia wrote:
> On Apr 6, 4:26 am, "andy" <(E-Mail Removed)> wrote:
>> 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?
 
Reply With Quote
 
andy
Guest
Posts: n/a
 
      04-07-2007
Thanks a lot.



On Apr 6, 11:35 pm, "J. Gleixner" <(E-Mail Removed)>
wrote:
> Xicheng Jia wrote:
> > On Apr 6, 4:26 am, "andy" <(E-Mail Removed)> wrote:
> >> 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?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i convert my perl script to be a perl module? georg.heiss@gmx.de Perl Misc 4 02-10-2009 06:21 PM
Re: module docstring, documentation,anything? please note is the module type/object NOT some module Maric Michaud Python 0 06-24-2006 12:42 PM
how to use Perl module - Perl Magick??? i am a newbie. jadkit@gmail.com Perl Misc 2 02-06-2006 05:59 PM
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 230. Feyruz Perl Misc 4 10-14-2005 06:47 PM
Converting a perl module to a python module would it be worth it? Mothra Python 5 04-15-2005 06:09 AM



Advertisments