Greetings, We've discovered a problem with the handling of simple expressions in HTML::Template::Expr 0.07. Briefly, if a variable "foo" is defined, an expression with just the variable name will fail. For example, both of these tags fail:
<tmpl_var expr="foo"> <tmpl_if expr="foo">Yes</tmpl_if> This used to work in version 0.04. We have a workaround in that we can convert to using a name attribute, i.e., <tmpl_var name="foo"> but we have a lot of templates and would like not to modify them. I looked a little closer at Expr.pm and found a bug in the discovery of variable names with no operators. The analysis always starts at the second level of the parse tree. The enclosed one line patch just wraps the test parse tree in an array while testing so that discovery will bare name variables. All unit tests pass after applying this. I've also enclosed a simple test case and template file to demonstrate this bug. It would be great if this could be folded into the official distribution. Let me know if you need any additional information about this. Thanks, Tim Walters --- Expr.pm~ 2007-02-14 22:36:11.000000000 -0800 +++ Expr.pm 2007-02-15 22:37:28.000000000 -0800 @@ -197,7 +197,7 @@ my %vars; # hunt for VAR nodes in the tree - my @stack = @$tree; + my @stack = ($tree); while (@stack) { my $node = shift @stack; if (ref $node and ref $node eq 'ARRAY') { --- /dev/null 2007-04-10 15:50:33.000000000 -0700 +++ t/50exprname.t 2007-02-15 15:27:26.000000000 -0800 @@ -0,0 +1,10 @@ +use Test::More tests => 2; +use HTML::Template::Expr; + +$template = HTML::Template::Expr->new(die_on_bad_params => 0, + path => ['t/templates'], + filename => 'nameexpr.tmpl'); +$template->param(foo => 100); +$output = $template->output(); +like($output, qr/100/, "<TMPL_VAR EXPR=\"name\"> works"); +like($output, qr/Yes/, "<TMPL_IF EXPR=\"name\"> works"); --- /dev/null 2007-04-10 15:55:27.000000000 -0700 +++ t/templates/nameexpr.tmpl 2007-02-15 15:24:58.000000000 -0800 @@ -0,0 +1,2 @@ +<tmpl_var expr="foo"> +<tmpl_if expr="foo">Yes</tmpl_if> ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users