Thread: RE: [htmltmpl] Comparing H::T:Expr variables
Brought to you by:
samtregar
From: Chris <chr...@co...> - 2003-11-20 01:11:18
Attachments:
smime.p7s
|
Hi Matt, Thank you so much for the reply. I had tried that, and that change yeilds 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. Yes, I am using use HTML::Template::Expr; in my perl script and it is the newest version. 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> with the updated "EXPR" Thanks!!! > -----Original Message----- > From: Mathew Robertson [mailto:mat...@re...] > Sent: Wednesday, November 19, 2003 7:28 PM > To: Chris; htm...@li... > Subject: Re: [htmltmpl] Comparing H::T:Expr variables > > > > > I seems that when I call: > > > > Model Name: <TMPL_VAR NAME=MODEL_NAME> > > Model Comp: <TMPL_VAR NAME="MODEL_COMP"> > > > > from within: <TMPL_LOOP URLLOOP> > > > > It prints the correct data. > > > > Now.. Since that works, am I just using the: > > > > <TMPL_IF NAME="MODEL_COMP eq MODEL_NAME"> > > > > Statement WRONG? The data between the IF statement never gets displayed. > > Yep, you need to use <TMPL_IF EXPR="MODEL_COMP eq MODEL_NAME"> > > Note the "EXPR". > > That should fix it... > > Mathew |
From: Chris <chr...@co...> - 2003-11-20 03:28:43
Attachments:
smime.p7s
|
Hi Matt, 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. Thanks!! > -----Original Message----- > From: Mathew Robertson [mailto:mat...@re...] > Sent: Wednesday, November 19, 2003 8:24 PM > To: Chris; htm...@li... > Subject: Re: [htmltmpl] Comparing H::T:Expr variables > > > > 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> > > It looks like you are missing a " after the EXPR ...? > Mat |
From: Mathew R. <mat...@re...> - 2003-11-20 03:42:45
|
The syntax that you are using is correct. I suspect that there is = another error some where. What happens if you use the 'strict =3D> 0' option to HTML::Template? =20 Mat > Yes I did forget the " before the EXPR but it still fails with: >=20 > <TMPL_IF EXPR=3D"MODEL_COMP eq MODEL_NAME"> >=20 > With the following error: >=20 > 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. >=20 > > > The new template file looks like: > > > > > > <TMPL_LOOP ROWS> > > > <br> > > > <br> > > > <TMPL_VAR NAME=3DMODEL_NAME> > > > <br> > > > <img src=3D"<TMPL_VAR NAME=3DMODEL_THUMB>" border=3D0 height=3D100 = width=3D100> > > > <br> > > > Can be seen at: > > > > > > <TMPL_LOOP URLLOOP> > > > Model Name: <TMPL_VAR NAME=3DMODEL_NAME> > > > Model Comp: <TMPL_VAR NAME=3DMODEL_COMP> > > > > > > <TMPL_IF EXPR=3DMODEL_COMP eq MODEL_NAME"> > > > Model Name: <TMPL_VAR NAME=3DMODEL_NAME> > > > Model Comp: <TMPL_VAR NAME=3DMODEL_COMP> > > > The URL on match: <TMPL_VAR NAME=3DMODEL_URL> > > > </TMPL_IF> > > > </TMPL_LOOP> > > > > > > </TMPL_LOOP> > > > <br> |
From: Chris <chr...@co...> - 2003-11-20 04:34:03
Attachments:
smime.p7s
|
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 => \@URLS, }); } $sth->finish(); $template->param( ROWS => \@ROWS ); 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: htm...@li... > [mailto:htm...@li...]On Behalf Of > Mathew Robertson > Sent: Wednesday, November 19, 2003 10:42 PM > To: Chris; htm...@li... > 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 > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Cees H. <ce...@si...> - 2003-11-20 05:11:08
|
Quoting Chris <chr...@co...>: > I just added the strict option on: > > my $template = HTML::Template->new(filename => 'index.tmpl', strict => 0, > global_vars => 1); You do mean HTML::Template::Expr in the above code right? You are getting the error because HTML::Template can't parse <TMPL_IF EXPR=""> correctly, so it sees a </TMPL_IF> without a matching <TMPL_IF> Cheers, Cees |
From: Mathew R. <mat...@re...> - 2003-11-20 05:13:44
|
Hi Chris, I am assuming that this snippets of script/template are not exactly the = same as your real code? If so, you reeeealllly should be calling 'use strict;' since I can see = that there are vairable definitions here that are not declared before = use. Perl will quite happily do this, thus auto-vivifying some of these = variables into globals - probably not what you really want to happen. Also, didn't you say that you were using HTML::Template::Expr > my $template =3D HTML::Template->new(filename =3D> 'index.tmpl', = strict =3D> 0,global_vars =3D> 1); > I really dont know why H::T is complaining about finding a <//TMPL_IF> > without a <TMPL_IF>, since there is, indeed one there. This complaint was because I told you to use "strict =3D> 0" thus H::T = is ignoring the <TMPL_IF EXPR....>, thus hitting the </TMPL_IF> without = finding the <TMPL_IF...>. Ignore this - this was expected, and thus = confirmed that the error was with the TMPL_IF. Try using H::T::E rather than H::T ? Mat > I will include my HTML template and source: >=20 > HTML Template: > <TMPL_LOOP ROWS> > <br> > <br> > <TMPL_VAR NAME=3DMODEL_NAME> > <br> > <img src=3D"<TMPL_VAR NAME=3DMODEL_THUMB>" border=3D0 = height=3D100 width=3D100> > <br> > Can be seen at: > <TMPL_LOOP URLLOOP> > Model Name: <TMPL_VAR NAME=3DMODEL_NAME> > Model Comp: <TMPL_VAR NAME=3DMODEL_COMP> > <TMPL_IF EXPR=3D"MODEL_COMP eq MODEL_NAME"> > Model Name: <TMPL_VAR NAME=3DMODEL_NAME> > Model Comp: <TMPL_VAR NAME=3DMODEL_COMP> > The URL on match: <TMPL_VAR NAME=3DMODEL_URL> > </TMPL_IF> > </TMPL_LOOP> > </TMPL_LOOP> > <br> >=20 >=20 > The Perl Script: > #!/usr/bin/perl > use DBI; > use CGI; > use HTML::Template; > use HTML::Template::Expr; >=20 > my $dbsource =3D "DBI:mysql:dbname=3Dmsearch;host=3Dlocalhost"; > my $dbuser =3D "chrisp"; > my $dbpasswd =3D "xxxxxxxx"; >=20 > my $template =3D HTML::Template->new(filename =3D> 'index.tmpl', = strict =3D> 0, global_vars =3D> 1); > my $bychar =3D 'c'; > my @URLS =3D (); > my @ROWS =3D (); >=20 > my $dbh =3D DBI->connect($dbsource, $dbuser, $dbpasswd); > my $dbh2 =3D DBI->connect($dbsource, $dbuser, $dbpasswd); >=20 > my $query =3D "SELECT DISTINCT model_name as model_name, model_thumb = FROM models WHERE model_firstchar =3D '$bychar' GROUP BY model_name"; > my $sth =3D $dbh->prepare($query); > $sth->execute() || die &error($DBI::errstr); >=20 > while (my $data =3D $sth->fetchrow_hashref) { > $model_name =3D $data->{model_name}; >=20 > my $query2 =3D "SELECT model_url FROM models where model_name = =3D '$model_name'"; > my $sth2 =3D $dbh2->prepare($query2); >=20 > $sth2->execute(); > $sth2->bind_columns(undef, \$model_url); >=20 > while($sth2->fetch()) { > push (@URLS, > { > MODEL_URL =3D> $model_url, > MODEL_COMP =3D> $data->{model_name} > } ); > } >=20 > push (@ROWS, > { > MODEL_NAME =3D> $data->{model_name}, > MODEL_THUMB =3D> $data->{model_thumb}, > URLLOOP =3D> \@URLS, > } > ); > } >=20 > $sth->finish(); >=20 > $template->param( ROWS =3D> \@ROWS ); > print $template->output; >=20 |
From: Todd C. <htm...@ch...> - 2003-11-20 05:41:29
|
Remove the "use HTML::Template" line. Keep the "HTML::Template::Expr" line. -Todd On Wed, Nov 19, 2003 at 11:32:29PM -0500, Chris wrote: > 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 => \@URLS, > }); > } > > $sth->finish(); > > $template->param( ROWS => \@ROWS ); > 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: htm...@li... > > [mailto:htm...@li...]On Behalf Of > > Mathew Robertson > > Sent: Wednesday, November 19, 2003 10:42 PM > > To: Chris; htm...@li... > > 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 > > Htm...@li... > > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Sam T. <sa...@tr...> - 2003-11-20 05:45:25
|
On Wed, 19 Nov 2003, Chris wrote: > my $template = HTML::Template->new(filename => 'index.tmpl', strict => 0, > global_vars => 1); You're calling HTML::Template->new(), but you should be calling HTML::Template::Expr->new(). -sam |
From: Chris <chr...@co...> - 2003-11-20 14:11:00
Attachments:
smime.p7s
|
Thank you everybody for your excellent help! Removing just HTML:Template-> did the trick!! And yes, this was real code from a script, but it was only a test script. I always use strict :) Thanks again everybody, everything is working great because of you all, especially Matt. Thanks!! > -----Original Message----- > From: htm...@li... > [mailto:htm...@li...]On Behalf Of Sam > Tregar > Sent: Thursday, November 20, 2003 1:46 AM > To: Chris > Cc: Mathew Robertson; htm...@li... > Subject: RE: [htmltmpl] Comparing H::T:Expr variables > > > On Wed, 19 Nov 2003, Chris wrote: > > > my $template = HTML::Template->new(filename => 'index.tmpl', > strict => 0, > > global_vars => 1); > > You're calling HTML::Template->new(), but you should be calling > HTML::Template::Expr->new(). > > -sam > > > ------------------------------------------------------- > 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 > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: Karen J. C. <si...@ph...> - 2003-11-20 01:24:36
|
On Wed, 19 Nov 2003, Chris wrote: C>HTML::Template->new() : Syntax error in <TMPL_*> tag at index.tmpl : 14. C>at /usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm line 2243. C> C>Yes, I am using use HTML::Template::Expr; in my perl script and it is the C>newest version. Wouldn't that error be HTML::Template::Expr->new() if you're using Expr? (I haven't used Expr, myself, so I could be wrong.) -- Karen J. Cravens si...@ph... |
From: Mathew R. <mat...@re...> - 2003-11-20 01:45:56
|
> Wouldn't that error be HTML::Template::Expr->new() if you're using = Expr? No, the HTML::Template module (rightly or wrongly) uses a hard-coded = text string for the wording "HTML::Template", rather than using = "ref($self)". This is not such a bad thing as it tell you exactly which module the = error is being generated in. Mat |
From: Mathew R. <mat...@re...> - 2003-11-20 01:24:40
|
> The new template file looks like: >=20 > <TMPL_LOOP ROWS> > <br> > <br> > <TMPL_VAR NAME=3DMODEL_NAME> > <br> > <img src=3D"<TMPL_VAR NAME=3DMODEL_THUMB>" border=3D0 height=3D100 = width=3D100> > <br> > Can be seen at: >=20 > <TMPL_LOOP URLLOOP> > Model Name: <TMPL_VAR NAME=3DMODEL_NAME> > Model Comp: <TMPL_VAR NAME=3DMODEL_COMP> >=20 > <TMPL_IF EXPR=3DMODEL_COMP eq MODEL_NAME"> > Model Name: <TMPL_VAR NAME=3DMODEL_NAME> > Model Comp: <TMPL_VAR NAME=3DMODEL_COMP> > The URL on match: <TMPL_VAR NAME=3DMODEL_URL> > </TMPL_IF> > </TMPL_LOOP> >=20 > </TMPL_LOOP> > <br> It looks like you are missing a " after the EXPR ...? Mat |