Hi Matt, Thanks for all your help.

I just added the strict option on:

my $template = HTML::Template->new(filename  => 'index.tmpl', strict => 0,
global_vars => 1);

And now I get the following error:

HTML::Template->new() : found <//TMPL_IF> with no matching <TMPL_IF> at
index.tmpl : line 16. at /usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm
line 2117.


I will include my HTML template and source:

HTML Template:
<TMPL_LOOP ROWS>
<br>
<br>
<TMPL_VAR NAME=MODEL_NAME>
<br>
<img src="<TMPL_VAR NAME=MODEL_THUMB>" border=0 height=100 width=100>
<br>
Can be seen at:
<TMPL_LOOP URLLOOP>
                Model Name: <TMPL_VAR NAME=MODEL_NAME>
                Model Comp: <TMPL_VAR NAME=MODEL_COMP>
<TMPL_IF EXPR="MODEL_COMP eq MODEL_NAME">
                Model Name: <TMPL_VAR NAME=MODEL_NAME>
                Model Comp: <TMPL_VAR NAME=MODEL_COMP>
                The URL on match: <TMPL_VAR NAME=MODEL_URL>
        </TMPL_IF>
</TMPL_LOOP>
</TMPL_LOOP>
<br>


The Perl Script:
#!/usr/bin/perl
use DBI;
use CGI;
use HTML::Template;
use HTML::Template::Expr;

my $dbsource = "DBI:mysql:dbname=msearch;host=localhost";
my $dbuser   = "chrisp";
my $dbpasswd = "xxxxxxxx";

my $template = HTML::Template->new(filename  => 'index.tmpl', strict => 0,
global_vars => 1);
my $bychar = 'c';
my @URLS = ();
my @ROWS = ();

my $dbh = DBI->connect($dbsource, $dbuser, $dbpasswd);
my $dbh2 = DBI->connect($dbsource, $dbuser, $dbpasswd);

my $query = "SELECT DISTINCT model_name as model_name, model_thumb FROM
models WHERE model_firstchar = '$bychar' GROUP BY model_name";
my $sth = $dbh->prepare($query);
$sth->execute() || die &error($DBI::errstr);

while (my $data = $sth->fetchrow_hashref) {
$model_name = $data->{model_name};

         my $query2 = "SELECT model_url FROM models where model_name =
'$model_name'";
         my $sth2 = $dbh2->prepare($query2);

         $sth2->execute();
         $sth2->bind_columns(undef, \$model_url);

        while($sth2->fetch()) {
                  push (@URLS, { MODEL_URL => $model_url, MODEL_COMP =>
$data->{model_name} });
        }

        push (@ROWS, { MODEL_NAME  => $data->{model_name},
                       MODEL_THUMB => $data->{model_thumb},
                       URLLOOP     => [EMAIL PROTECTED],
                     });
}

$sth->finish();

$template->param( ROWS => [EMAIL PROTECTED] );
print $template->output;

I really dont know why H::T is complaining about finding a <//TMPL_IF>
without a <TMPL_IF>, since there is, indeed one there.

Thanks!


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Mathew Robertson
> Sent: Wednesday, November 19, 2003 10:42 PM
> To: Chris; [EMAIL PROTECTED]
> Subject: Re: [htmltmpl] Comparing H::T:Expr variables
>
>
> The syntax that you are using is correct.  I suspect that there
> is another error some where.
>
> What happens if you use the 'strict => 0' option to HTML::Template?
>
> Mat
>
>
> > Yes I did forget the " before the EXPR but it still fails with:
> >
> > <TMPL_IF EXPR="MODEL_COMP eq MODEL_NAME">
> >
> > With the following error:
> >
> > HTML::Template->new() : Syntax error in <TMPL_*> tag at index.tmpl :
14.
> > at /usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm line 2243.
> >
> > > > The new template file looks like:
> > > >
> > > > <TMPL_LOOP ROWS>
> > > > <br>
> > > > <br>
> > > > <TMPL_VAR NAME=MODEL_NAME>
> > > > <br>
> > > > <img src="<TMPL_VAR NAME=MODEL_THUMB>" border=0 height=100
> width=100>
> > > > <br>
> > > > Can be seen at:
> > > >
> > > > <TMPL_LOOP URLLOOP>
> > > >                 Model Name: <TMPL_VAR NAME=MODEL_NAME>
> > > >                 Model Comp: <TMPL_VAR NAME=MODEL_COMP>
> > > >
> > > >         <TMPL_IF EXPR=MODEL_COMP eq MODEL_NAME">
> > > >                 Model Name: <TMPL_VAR NAME=MODEL_NAME>
> > > >                 Model Comp: <TMPL_VAR NAME=MODEL_COMP>
> > > >                 The URL on match: <TMPL_VAR NAME=MODEL_URL>
> > > >         </TMPL_IF>
> > > > </TMPL_LOOP>
> > > >
> > > > </TMPL_LOOP>
> > > > <br>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Html-template-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/html-template-users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to