HTML::template Module in perl

Discussion in 'Perl Misc' started by andy, Apr 6, 2007.

  1. andy

    andy Guest

    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
    andy, Apr 6, 2007
    #1
    1. Advertising

  2. andy

    Xicheng Jia Guest

    On Apr 6, 4:26 am, "andy" <> 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
    Xicheng Jia, Apr 6, 2007
    #2
    1. Advertising

  3. andy

    J. Gleixner Guest

    Xicheng Jia wrote:
    > On Apr 6, 4:26 am, "andy" <> 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?
    J. Gleixner, Apr 6, 2007
    #3
  4. andy

    andy Guest

    Thanks a lot.



    On Apr 6, 11:35 pm, "J. Gleixner" <>
    wrote:
    > Xicheng Jia wrote:
    > > On Apr 6, 4:26 am, "andy" <> 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?
    andy, Apr 7, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Theis
    Replies:
    2
    Views:
    457
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    525
    tom_usenet
    Jul 24, 2003
  3. ChrisO
    Replies:
    8
    Views:
    159
    ChrisO
    Sep 15, 2004
  4. C. Olive
    Replies:
    1
    Views:
    247
    Chris Smith
    Oct 4, 2003
  5. andy

    HTML::Template module in perl

    andy, Apr 9, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    206
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page