r45796 - in /trunk/libhtml-template-expr-perl: ./ debian/ t/ t/templates/

emhn-guest at users.alioth.debian.org emhn-guest at users.alioth.debian.org
Wed Oct 14 16:05:06 UTC 2009


Author: emhn-guest
Date: Wed Oct 14 16:04:50 2009
New Revision: 45796

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=45796
Log:
* New upstream release (Closes: 548544).
  <isaac at debian.org> removed from Uploaders as per his request.
  Changed: added myself in Uploaders.
* Updated Standards Version.
* Upgraded to DH7 using dh-make-perl.
* Remove debian/docs and use debian/libhtml-template-expr-perl.docs 
  instead. Remove README from it since it's just a copy of the POD.
* debian/copyright: Move to new parsable format and add missing
  copyright information.
* Take over for the Debian Perl Group.
  Isaac, thank you very much for your work on this package.

Added:
    trunk/libhtml-template-expr-perl/debian/libhtml-template-expr-perl.docs
    trunk/libhtml-template-expr-perl/t/05cache.t
    trunk/libhtml-template-expr-perl/t/06extra_attributes.t
    trunk/libhtml-template-expr-perl/t/templates/extra_attributes.tmpl
Removed:
    trunk/libhtml-template-expr-perl/debian/docs
Modified:
    trunk/libhtml-template-expr-perl/ANNOUNCE
    trunk/libhtml-template-expr-perl/Changes
    trunk/libhtml-template-expr-perl/Expr.pm
    trunk/libhtml-template-expr-perl/MANIFEST
    trunk/libhtml-template-expr-perl/META.yml
    trunk/libhtml-template-expr-perl/debian/changelog
    trunk/libhtml-template-expr-perl/debian/compat
    trunk/libhtml-template-expr-perl/debian/control
    trunk/libhtml-template-expr-perl/debian/copyright
    trunk/libhtml-template-expr-perl/debian/rules
    trunk/libhtml-template-expr-perl/t/01parse.t
    trunk/libhtml-template-expr-perl/t/03complex.t
    trunk/libhtml-template-expr-perl/t/04register.t
    trunk/libhtml-template-expr-perl/t/templates/complex.tmpl
    trunk/libhtml-template-expr-perl/t/templates/register.tmpl

Modified: trunk/libhtml-template-expr-perl/ANNOUNCE
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/ANNOUNCE?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/ANNOUNCE (original)
+++ trunk/libhtml-template-expr-perl/ANNOUNCE Wed Oct 14 16:04:50 2009
@@ -1,8 +1,14 @@
-ANNOUNCEMENT: HTML::Template::Expr 0.05
+ANNOUNCEMENT: HTML::Template::Expr 0.07
 
 CHANGES
 
-    - Added a compatibility fix required by HTML::Template v2.8.
+    - Added support for ESCAPE attribute in combination with EXPR.
+      (Michael Peters)
+
+    - Fixed a bug where functions which returned 0 or more than one
+      return value would cause a stack under or overflow.  Functions
+      are now called in scalar context, eliminating the problem.
+      Thanks to Jamie Krasnoo for the spot.
 
 DESCRIPTION
 

Modified: trunk/libhtml-template-expr-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/Changes?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/Changes (original)
+++ trunk/libhtml-template-expr-perl/Changes Wed Oct 14 16:04:50 2009
@@ -1,22 +1,18 @@
-Revision history for HTML::Template::Expr.
+0.07
+    - Added support for ESCAPE attribute in combination with EXPR.
+      (Michael Peters)
 
-0.01  
-    - Initial Release.
+    - Fixed a bug where functions which returned 0 or more than one
+      return value would cause a stack under or overflow.  Functions
+      are now called in scalar context, eliminating the problem.
+      Thanks to Jamie Krasnoo for the spot.
 
-0.02    
-    - Fixed bug where numeric functions all returned 1. 
-      (reported by Peter Leonard)
+0.06
+    - Rewrote grammar to support expressions with less parenthesis.
+      For example, "foo || bar || baz" now works.
 
-    - Improved performance over 300% with a new grammar and expression 
-      evaluator.
-
-    - Enhanced grammar to support call(foo > 10) syntax.
-
-0.03
-    - Added register_function() class method add functions globally. 
-      (Tatsuhiko Miyagawa)
-
-    - Fixed broken cache mode.
+0.05 Wed Dec 21 18:56:49 EST 2005
+    - Added a compatibility fix required by HTML::Template v2.8.
 
 0.04 Thu Aug 29 12:00:00 2002
     - Fixed parser to recognize negative numbers.  Thanks to Fran
@@ -28,5 +24,21 @@
     - Updated mailing-list information to reflect move from vm.com to
       sourceforge.net
 
-0.05 Wed Dec 21 18:56:49 EST 2005
-    - Added a compatibility fix required by HTML::Template v2.8.
+0.03
+    - Added register_function() class method add functions globally. 
+      (Tatsuhiko Miyagawa)
+
+    - Fixed broken cache mode.
+
+0.02    
+    - Fixed bug where numeric functions all returned 1. 
+      (reported by Peter Leonard)
+
+    - Improved performance over 300% with a new grammar and expression 
+      evaluator.
+
+    - Enhanced grammar to support call(foo > 10) syntax.
+
+0.01  
+    - Initial Release.
+

Modified: trunk/libhtml-template-expr-perl/Expr.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/Expr.pm?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/Expr.pm (original)
+++ trunk/libhtml-template-expr-perl/Expr.pm Wed Oct 14 16:04:50 2009
@@ -3,7 +3,7 @@
 use strict;
 use vars qw($VERSION);
 
-$VERSION = '0.05';
+$VERSION = '0.07';
 
 use HTML::Template 2.4;
 use Carp qw(croak confess carp);
@@ -11,46 +11,44 @@
 
 use base 'HTML::Template';
 
-# constants used in the expression tree
-use constant BIN_OP          => 1;
-use constant FUNCTION_CALL   => 2;
-
 use vars qw($GRAMMAR);
-$GRAMMAR = <<END;
-expression    : subexpression /^\$/  { \$return = \$item[1]; } 
-
-subexpression : binary_op             { \$item[1] }
-              | function_call         { \$item[1] }
-              | var                   { \$item[1] }
-              | literal               { \$item[1] }
-              | '(' subexpression ')' { \$item[2] }
+$GRAMMAR = <<'END';
+expression : paren /^$/  { $return = $item[1] } 
+
+paren         : '(' binary_op ')'     { $item[2] }
+              | '(' subexpression ')' { $item[2] }
+              | subexpression         { $item[1] }
+              | '(' paren ')'         { $item[2] }
+
+subexpression : function_call
+              | var
+              | literal
               | <error>
 
-binary_op     : '(' subexpression op subexpression ')'
-                { [ \$item[3][0], \$item[3][1], \$item[2], \$item[4] ] }
-
-op            : />=?|<=?|!=|==/      { [ ${\BIN_OP},  \$item[1] ] }
-              | /le|ge|eq|ne|lt|gt/  { [ ${\BIN_OP},  \$item[1] ] }
-              | /\\|\\||or|&&|and/   { [ ${\BIN_OP},  \$item[1] ] }
-              | /[-+*\\/\%]/         { [ ${\BIN_OP},  \$item[1] ] }
+binary_op     : paren (op paren { [ $item[2], $item[1] ] })(s)
+              { $return = [ 'SUB_EXPR', $item[1], map { @$_ } @{$item[2]} ] }
+
+op            : />=?|<=?|!=|==/      { [ 'BIN_OP',  $item[1] ] }
+              | /le|ge|eq|ne|lt|gt/  { [ 'BIN_OP',  $item[1] ] }
+              | /\|\||or|&&|and/     { [ 'BIN_OP',  $item[1] ] }
+              | /[-+*\/%]/           { [ 'BIN_OP',  $item[1] ] }
 
 function_call : function_name '(' args ')'  
-                { [ ${\FUNCTION_CALL}, \$item[1], \$item[3] ] }
-              | function_name ...'(' subexpression
-                { [ ${\FUNCTION_CALL}, \$item[1], [ \$item[3] ] ] }
+                { [ 'FUNCTION_CALL', $item[1], $item[3] ] }
+              | function_name ...'(' paren
+                { [ 'FUNCTION_CALL', $item[1], [ $item[3] ] ] }
               | function_name '(' ')'
-                { [ ${\FUNCTION_CALL}, \$item[1] ] }
+                { [ 'FUNCTION_CALL', $item[1] ] }
 
 function_name : /[A-Za-z_][A-Za-z0-9_]*/
-                { \$item[1] }
-
-args          : <leftop: subexpression ',' subexpression>
-
-var           : /[A-Za-z_][A-Za-z0-9_]*/  { \\\$item[1] }
-
-literal       : /-?\\d*\\.\\d+/           { \$item[1] }
-              | /-?\\d+/                  { \$item[1] }
-              | <perl_quotelike>          { \$item[1][2] }
+
+args          : <leftop: paren ',' paren>
+
+var           : /[A-Za-z_][A-Za-z0-9_]*/ { [ 'VAR', $item[1] ] }
+
+literal       : /-?\d*\.\d+/             { [ 'LITERAL', $item[1] ] }
+              | /-?\d+/                  { [ 'LITERAL', $item[1] ] }
+              | <perl_quotelike>         { [ 'LITERAL', $item[1][2] ] }
 
 END
 
@@ -149,11 +147,21 @@
   my $text = shift;
 
   # find expressions and create parse trees
-  my ($ref, $tree, $expr_text, $vars, $which, $out);
-  $$text =~ s/<(?:!--\s*)?[Tt][Mm][Pp][Ll]_([Ii][Ff]|[Uu][Nn][Ll][Ee][Ss][Ss]|[Vv][Aa][Rr])\s+[Ee][Xx][Pp][Rr]="(.*?)"\s*(?:--)?>
+  my ($ref, $tree, $before_expr, $expr_text, $after_expr, $vars, $which, $out);
+  $$text =~ s/
+               <(?:!--\s*)?
+               [Tt][Mm][Pp][Ll]_
+               ([Ii][Ff]|[Uu][Nn][Ll][Ee][Ss][Ss]|[Vv][Aa][Rr]) # $1 => which tag
+               (\s+[^<]+)?                                      # $2 => before expr
+               \s+[Ee][Xx][Pp][Rr]=
+               "([^"]*)"                                        # $3 => the actual expr
+               (\s+[^>-]+)?                                     # $4 => after expr
+               \s*(?:--)?>
              /
-               $which = $1;
-               $expr_text = $2;  
+               $which       = $1;
+               $before_expr = $2 || '';
+               $expr_text   = $3;  
+               $after_expr  = $4 || '';
 
                # add enclosing parens to keep grammar simple
                $expr_text = "($expr_text)";
@@ -176,7 +184,7 @@
                push(@$expr, $tree);
                
                # add the expression placeholder and replace
-               $out . "<\/tmpl_if><tmpl_$which __expr_" . $#{$expr} . "__>";
+               $out . "<\/tmpl_if><tmpl_$which ${before_expr}__expr_" . $#{$expr} . "__$after_expr>";
              /xeg;
   # stupid emacs - /
 
@@ -185,25 +193,22 @@
 
 # find all variables in a parse tree
 sub _expr_vars {
-  my %vars;
-
-  while(@_) {
-    my $node = shift;
-    if (ref($node)) {
-      if (ref $node eq 'SCALAR') {
-	# found a variable
-	$vars{$$node} = 1;
-      } elsif ($node->[0] == FUNCTION_CALL) {
-	# function calls
-	push(@_, @{$node->[2]}) if defined $node->[2];
-      } else {
-	# binary ops
-	push(@_, $node->[2], $node->[3]);
-      }
+    my $tree = shift;
+    my %vars;
+
+    # hunt for VAR nodes in the tree
+    my @stack = @$tree;
+    while (@stack) {
+        my $node = shift @stack;
+        if (ref $node and ref $node eq 'ARRAY') {
+            if ($node->[0] eq 'VAR') {
+                $vars{$node->[1]} = 1;
+            } else {
+                push @stack, @$node;
+            }
+        }
     }
-  }
-
-  return keys %vars;
+    return keys %vars;
 }
 
 # allow loops to stay as HTML::Template objects, we don't need to
@@ -239,7 +244,7 @@
   # setup %FUNC 
   local %FUNC = (%FUNC, %$expr_func);
 
-  my $result = HTML::Template::output($self, @_);
+  my $result = $self->SUPER::output(@_);
 
   # restore cached values to their hideout in the parse_stack
   if ($options->{cache}) {
@@ -252,79 +257,111 @@
 
 sub _expr_evaluate {
   my ($tree, $template) = @_;
-  my ($op, $lhs, $rhs);
-
-  # return literals up
-  return $tree unless ref $tree;
-
-  # lookup vars
-  return $template->param($$tree)
-    if ref $tree eq 'SCALAR';
-
-  my $type = $tree->[0];
-
-  # handle binary expressions
-  if ($type == BIN_OP) {
-    ($op, $lhs, $rhs) = ($tree->[1], $tree->[2], $tree->[3]);
-
-    # recurse and resolve subexpressions
-    $lhs = _expr_evaluate($lhs, $template) if ref($lhs);
-    $rhs = _expr_evaluate($rhs, $template) if ref($rhs);
+  my ($op, $lhs, $rhs, $node, $type, @stack);
+
+  my @nodes = $tree;
+  while (@nodes) {
+      my $node = shift @nodes;
+      my $type = $node->[0];
+
+      if ($type eq 'LITERAL') {
+          push @stack, $node->[1];
+          next;
+      }
+
+      if ($type eq 'VAR') {
+          push @stack, $template->param($node->[1]);
+          next;
+      } 
+
+      if ($type eq 'SUB_EXPR') {
+          unshift @nodes, @{$node}[1..$#{$node}];
+          next;
+      }
+
+      if ($type eq 'BIN_OP') {
+          $op  = $node->[1];
+          $rhs = pop(@stack);
+          $lhs = pop(@stack);
+
+          # do the op
+          if ($op eq '==') {push @stack, $lhs == $rhs; next; }
+          if ($op eq 'eq') {push @stack, $lhs eq $rhs; next; }
+          if ($op eq '>')  {push @stack, $lhs >  $rhs; next; }
+          if ($op eq '<')  {push @stack, $lhs <  $rhs; next; }
+
+          if ($op eq '!=') {push @stack, $lhs != $rhs; next; }
+          if ($op eq 'ne') {push @stack, $lhs ne $rhs; next; }
+          if ($op eq '>=') {push @stack, $lhs >= $rhs; next; }
+          if ($op eq '<=') {push @stack, $lhs <= $rhs; next; }
+          
+          if ($op eq '+')  {push @stack, $lhs + $rhs;  next; }
+          if ($op eq '-')  {push @stack, $lhs - $rhs;  next; }
+          if ($op eq '/')  {push @stack, $lhs / $rhs;  next; }
+          if ($op eq '*')  {push @stack, $lhs * $rhs;  next; }
+          if ($op eq '%')  {push @stack, $lhs % $rhs;  next; }
+
+          if ($op eq 'le') {push @stack, $lhs le $rhs; next; }
+          if ($op eq 'ge') {push @stack, $lhs ge $rhs; next; }
+          if ($op eq 'lt') {push @stack, $lhs lt $rhs; next; }
+          if ($op eq 'gt') {push @stack, $lhs gt $rhs; next; }
+
+          # short circuit or
+          if ($op eq 'or' or $op eq '||') {
+              if ($lhs) {
+                  push @stack, 1;
+                  next;
+              }
+              if ($rhs) {
+                  push @stack, 1;
+                  next;
+              }
+              push @stack, 0;
+              next;
+          } 
+
+          # short circuit and
+          if ($op eq '&&' or $op eq 'and') {
+              unless ($lhs) {
+                  push @stack, 0;
+                  next;
+              }
+              unless ($rhs) {
+                  push @stack, 0;
+                  next;
+              }
+              push @stack, 1;
+              next;
+          }
     
-    # do the op
-    $op eq '==' and return $lhs == $rhs;
-    $op eq 'eq' and return $lhs eq $rhs;
-    $op eq '>'  and return $lhs >  $rhs;
-    $op eq '<'  and return $lhs <  $rhs;
-
-    $op eq '!=' and return $lhs != $rhs; 
-    $op eq 'ne' and return $lhs ne $rhs;
-    $op eq '>=' and return $lhs >= $rhs;
-    $op eq '<=' and return $lhs <= $rhs;
-
-    $op eq '+' and return $lhs + $rhs;
-    $op eq '-' and return $lhs - $rhs;
-    $op eq '/' and return $lhs / $rhs;
-    $op eq '*' and return $lhs * $rhs;
-    $op eq '%' and return $lhs %  $rhs;
-
-    if ($op eq 'or' or $op eq '||') {
-      # short circuit or
-      $lhs = _expr_evaluate($lhs, $template) if ref $lhs;
-      return 1 if $lhs;
-      $rhs = _expr_evaluate($rhs, $template) if ref $rhs;
-      return 1 if $rhs;
-      return 0;
-    } else {
-      # short circuit and
-      $lhs = _expr_evaluate($lhs, $template) if ref $lhs;
-      return 0 unless $lhs;
-      $rhs = _expr_evaluate($rhs, $template) if ref $rhs;
-      return 0 unless $rhs;
-      return 1;
-    }
-
-    $op eq 'le' and return $lhs le $rhs;
-    $op eq 'ge' and return $lhs ge $rhs;
-    $op eq 'lt' and return $lhs lt $rhs;
-    $op eq 'gt' and return $lhs gt $rhs;
-    
-    confess("HTML::Template::Expr : unknown op: $op");
+          confess("HTML::Template::Expr : unknown op: $op");
+      } 
+
+      if ($type eq 'FUNCTION_CALL') {
+          my $name = $node->[1];
+          my $args = $node->[2];
+          croak("HTML::Template::Expr : found unknown subroutine call ".
+                ": $name.\n")
+            unless exists($FUNC{$name});
+          if (defined $args) {
+              push @stack, 
+                scalar 
+                  $FUNC{$name}->(map { _expr_evaluate($_, $template) } @$args);
+          } else {
+              push @stack, scalar $FUNC{$name}->();
+          }
+          next;
+      }
+
+      confess("HTML::Template::Expr : unrecognized node in tree: $node");
   }
 
-  if ($type == FUNCTION_CALL) {
-    croak("HTML::Template::Expr : found unknown subroutine call : $tree->[1]\n") unless exists($FUNC{$tree->[1]});
-
-    if (defined $tree->[2]) {
-      return $FUNC{$tree->[1]}->(
-	 map { _expr_evaluate($_, $template) } @{$tree->[2]}
-      );
-    } else {
-      return $FUNC{$tree->[1]}->();
-    }
+  unless (@stack == 1) {
+      confess("HTML::Template::Expr : stack overflow!  ".
+              "Please report this bug to the maintainer.");
   }
 
-  croak("HTML::Template::Expr : fell off the edge of _expr_evaluate()!  This is a bug - please report it to the author.");
+  return $stack[0];
 }
 
 sub register_function {
@@ -423,15 +460,14 @@
 
    <TMPL_VAR EXPR="sprintf('%d', foo)">
 
-The parser is currently rather simple, so all compound expressions
-must be parenthesized.  Examples:
-
-   <TMPL_VAR EXPR="(10 + foo) / bar">
-
-   <TMPL_IF EXPR="(foo % 10) > (bar + 1)">
-
-If you don't like this rule please feel free to contribute a patch
-to improve the parser's grammar.
+You can string together operators to produce complex booleans:
+
+  <TMPL_IF EXPR="(foo || bar || baz || (bif && bing) || (bananas > 10))">
+      I'm in a complex situation.
+  </TMPL_IF>
+
+The parser is pretty simple, so you may need to use parenthesis to get
+the desired precedence.
 
 =head1 COMPARISON
 
@@ -657,6 +693,7 @@
 
    Peter Leonard
    Tatsuhiko Miyagawa
+   Don Brodale
 
 Thanks!
 

Modified: trunk/libhtml-template-expr-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/MANIFEST?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/MANIFEST (original)
+++ trunk/libhtml-template-expr-perl/MANIFEST Wed Oct 14 16:04:50 2009
@@ -8,6 +8,8 @@
 t/02basic.t
 t/03complex.t
 t/04register.t
+t/05cache.t
+t/06extra_attributes.t
 t/templates/foo.tmpl
 t/templates/complex.tmpl
 t/templates/loop.tmpl
@@ -16,6 +18,7 @@
 t/templates/numerics.tmpl
 t/templates/register.tmpl
 t/templates/negative.tmpl
+t/templates/extra_attributes.tmpl
 GPL
 ARTISTIC
 ANNOUNCE

Modified: trunk/libhtml-template-expr-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/META.yml?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/META.yml (original)
+++ trunk/libhtml-template-expr-perl/META.yml Wed Oct 14 16:04:50 2009
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         HTML-Template-Expr
-version:      0.05
+version:      0.07
 version_from: Expr.pm
 installdirs:  site
 requires:

Modified: trunk/libhtml-template-expr-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/debian/changelog?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/debian/changelog (original)
+++ trunk/libhtml-template-expr-perl/debian/changelog Wed Oct 14 16:04:50 2009
@@ -1,18 +1,27 @@
-libhtml-template-expr-perl (0.05-3) UNRELEASED; urgency=low
+libhtml-template-expr-perl (0.07-1) UNRELEASED; urgency=low
 
+  * New upstream release (Closes: 548544).
   * debian/control: Added: Vcs-Svn field (source stanza); Vcs-Browser
     field (source stanza); Homepage field (source stanza);
     ${misc:Depends} to Depends: field. Changed: Maintainer set to Debian
     Perl Group <pkg-perl-maintainers at lists.alioth.debian.org> (was:
     Isaac Clerencia <isaac at debian.org>); Isaac Clerencia
-    <isaac at debian.org> moved to Uploaders.
+    <isaac at debian.org> removed from Uploaders as per his request.
+    Changed: added myself in Uploaders.
+  * Updated Standards Version.
+  * Upgraded to DH7 using dh-make-perl.
   * Add debian/watch.
+  * Remove debian/docs and use debian/libhtml-template-expr-perl.docs 
+    instead. Remove README from it since it's just a copy of the POD.
+  * debian/copyright: Move to new parsable format and add missing
+    copyright information.
 
- -- Ernesto Hernández-Novich (USB) <emhn at usb.ve>  Wed, 14 Oct 2009 11:13:08 -0430
+ -- Ernesto Hernández-Novich (USB) <emhn at usb.ve>  Wed, 14 Oct 2009 11:28:30 -0430
 
 libhtml-template-expr-perl (0.05-2) unstable; urgency=low
 
-  * Take over for the Debian Perl Group
+  * Take over for the Debian Perl Group.
+    Isaac, thank you very much for your work on this package.
 
  -- Ernesto Hernández-Novich (USB) <emhn at usb.ve>  Wed, 14 Oct 2009 11:12:53 -0430
 

Modified: trunk/libhtml-template-expr-perl/debian/compat
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/debian/compat?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/debian/compat (original)
+++ trunk/libhtml-template-expr-perl/debian/compat Wed Oct 14 16:04:50 2009
@@ -1,1 +1,1 @@
-5
+7

Modified: trunk/libhtml-template-expr-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/debian/control?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/debian/control (original)
+++ trunk/libhtml-template-expr-perl/debian/control Wed Oct 14 16:04:50 2009
@@ -2,17 +2,18 @@
 Section: perl
 Priority: optional
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Isaac Clerencia <isaac at debian.org>
-Build-Depends: debhelper (>= 4.0.0)
-Build-Depends-Indep: libhtml-template-perl, libparse-recdescent-perl
-Standards-Version: 3.6.1
+Uploaders: Ernesto Hernández-Novich (USB) <emhn at usb.ve>
+Build-Depends: debhelper (>= 7)
+Build-Depends-Indep: perl, libhtml-template-perl, libparse-recdescent-perl
+Standards-Version: 3.8.3
 Homepage: http://search.cpan.org/dist/HTML-Template-Expr/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libhtml-template-expr-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libhtml-template-expr-perl/
 
 Package: libhtml-template-expr-perl
 Architecture: all
-Depends: ${misc:Depends}, ${shlibs:Depends}, libhtml-template-perl, libparse-recdescent-perl
+Depends: ${misc:Depends}, ${perl:Depends}, libhtml-template-perl,
+ libparse-recdescent-perl
 Description: HTML::Template extension adding expression support
  This module provides an extension to HTML::Template which allows expressions
  in the template syntax. This is purely an addition - all the normal 

Modified: trunk/libhtml-template-expr-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/debian/copyright?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/debian/copyright (original)
+++ trunk/libhtml-template-expr-perl/debian/copyright Wed Oct 14 16:04:50 2009
@@ -1,16 +1,29 @@
-This package was debianized by
-Isaac Clerencia <isaac at sindominio.net> on Wed, 04 Aug 2004 16:51:39 +0100.
+Format-Specification:
+    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
+Upstream-Maintainer: Sam Tregar <sam at tregar.com>
+Upstream-Source: http://search.cpan.org/dist/HTML-Template-Expr/
+Upstream-Name: HTML-Template-Expr
 
-It was downloaded from http://search.cpan.org/~samtregar/HTML-Template-Expr-0.04/
+Files: *
+Copyright: 2001, Sam Tregar <sam at tregar.com>
+License: Artistic | GPL-1+
 
-Upstream Author: Sam Tregar <sam at tregar.com>
+Files: debian/*
+Copyright: 2004, Isaac Clerencia <isaac at sindominio.net>
+ 2006, Isaac Clerencia <isaac at debian.org>
+ 2009, Ernesto Hernández-Novich (USB) <emhn at usb.ve>
+License: Artistic | GPL-1+
 
-Copyright (c) 2001, Sam Tregar
+License: Artistic
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the Artistic License, which comes with Perl.
+    On Debian GNU/Linux systems, the complete text of the Artistic License
+    can be found in `/usr/share/common-licenses/Artistic'
 
-License:
-	This module is free software; you can redistribute it and/or modify
-	it under the terms of the "Artistic License" OR the GPL.
-
-	On Debian systems, the complete text of the Artistic License
-	can be found in /usr/share/common-licenses/Artistic and the
-	complete text of the GPL can be found in /usr/share/common-licenses/GPL.
+License: GPL-1+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 1, or (at your option)
+    any later version.
+    On Debian GNU/Linux systems, the complete text of the GNU General
+    Public License can be found in `/usr/share/common-licenses/GPL'

Added: trunk/libhtml-template-expr-perl/debian/libhtml-template-expr-perl.docs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/debian/libhtml-template-expr-perl.docs?rev=45796&op=file
==============================================================================
--- trunk/libhtml-template-expr-perl/debian/libhtml-template-expr-perl.docs (added)
+++ trunk/libhtml-template-expr-perl/debian/libhtml-template-expr-perl.docs Wed Oct 14 16:04:50 2009
@@ -1,0 +1,1 @@
+ANNOUNCE

Modified: trunk/libhtml-template-expr-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/debian/rules?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/debian/rules (original)
+++ trunk/libhtml-template-expr-perl/debian/rules Wed Oct 14 16:04:50 2009
@@ -1,65 +1,4 @@
 #!/usr/bin/make -f
-# Sample debian/rules that uses debhelper.
-# GNU copyright 1997 to 1999 by Joey Hess.
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-ifndef PERL
-PERL = /usr/bin/perl
-endif
-
-build: build-stamp
-build-stamp:
-	dh_testdir
-
-	# Add here commands to compile the package.
-	$(PERL) Makefile.PL INSTALLDIRS=vendor
-	$(MAKE)
-	$(MAKE) test
-
-	touch build-stamp
-
-clean:
-	dh_testdir
-	dh_testroot
-	rm -f build-stamp
-
-	# Add here commands to clean up after the build process.
-	-$(MAKE) clean
-	-$(MAKE) distclean
-	rm -f Makefile Makefile.old
-
-	dh_clean
-
-install: build
-	dh_testdir
-	dh_testroot
-	dh_clean -k
-	dh_installdirs
-	dh_install
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir
-	dh_testroot
-
-	dh_installdocs
-	dh_installchangelogs Changes
-	dh_installman
-	dh_link
-	dh_strip
-	dh_compress
-	dh_fixperms
-	dh_installdeb
-	dh_shlibdeps
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+%:
+	dh $@

Modified: trunk/libhtml-template-expr-perl/t/01parse.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/01parse.t?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/t/01parse.t (original)
+++ trunk/libhtml-template-expr-perl/t/01parse.t Wed Oct 14 16:04:50 2009
@@ -1,19 +1,24 @@
-use Test::More tests => 14;
+use Test::More qw(no_plan);
+use Parse::RecDescent;
+
+use constant DEBUG => 0;
+$::RD_HINT = DEBUG;
+# $::RD_TRACE = 1;
+
 use HTML::Template::Expr;
-use Parse::RecDescent;
 use Data::Dumper;
 
-use constant DEBUG => 0;
+
 
 # test grammar directly
-$::RD_HINT = 1 if DEBUG;
+
 my @tests = (
              "(foo > 10)",
              "((foo < 10) != (bar > 10))",
              "('foo' eq 'bar')",
              "((foo + 10.1) > 100)",
              "(((foo > 10) || (200 < bar)) + 10.5)",
-             "(call(foo, 10))",
+             "(call(foo, 10, 20, 30))",
              "(call(foo, 10) > 10)",
              "(first( foo, 10 ))",
              "(call(foo, \"baz\", 10) eq 'string val')", 
@@ -21,17 +26,21 @@
              "(((call(foo, 10) + 100) > 10) || (foo eq \"barf\"))",
              "((foo > bar))",
 	     "call(call2(call3()))",
-	     "call(foo > bar)"
+	     "call(foo > bar)",
+             "(foo || bar || baz || bif)",
+             "((foo || bar || baz) && bif)",
+             "((foo || bar || baz) && (bif || 10))",
 	    );
 
 foreach my $test (@tests) {
- my $tree = $HTML::Template::Expr::PARSER->expression($test);
- ok($tree, "parsing \"$test\"");
- if (DEBUG) {
-   local $Data::Dumper::Indent = 1;
-   local $Data::Dumper::Purity = 0;
-   local $Data::Dumper::Deepcopy = 1;
-   print STDERR Data::Dumper->Dump([\$tree],['$tree']);
-   print STDERR "vars: ", join(',', HTML::Template::Expr::_expr_vars($tree)), "\n\n";
- }
+    print STDERR "TRYING TO PARSE $test\n" if DEBUG;
+    my $tree = $HTML::Template::Expr::PARSER->expression($test);
+    ok($tree, "parsing \"$test\"");
+    if (DEBUG) {
+        local $Data::Dumper::Indent = 1;
+        local $Data::Dumper::Purity = 0;
+        local $Data::Dumper::Deepcopy = 1;
+        print STDERR Data::Dumper->Dump([\$tree],['$tree']);
+        print STDERR "vars: ", join(',', HTML::Template::Expr::_expr_vars($tree)), "\n\n";
+    }
 }

Modified: trunk/libhtml-template-expr-perl/t/03complex.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/03complex.t?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/t/03complex.t (original)
+++ trunk/libhtml-template-expr-perl/t/03complex.t Wed Oct 14 16:04:50 2009
@@ -1,4 +1,4 @@
-use Test::More tests => 18;
+use Test::More qw(no_plan);
 use HTML::Template::Expr;
 
 my $template = HTML::Template::Expr->new(path => ['t/templates'],
@@ -15,13 +15,19 @@
                  unused => 0);
 my $output = $template->output();
 like($output, qr/Foo is greater than 10/i, "greater than");
-ok($output !~ qr/Bar and Foo/i, "and");
+unlike($output, qr/Bar and Foo/i, "and");
 like($output, qr/Bar or Foo/i, "or");
 like($output, qr/Bar - Foo = -11/i, "subtraction");
+like($output, qr/Foo - Bar \+ 10 = 21/i, "math strings");
 like($output, qr/Math Works, Alright/i, "math");
 like($output, qr/My name is President Clinton/, "string op 1");
 like($output, qr/Resident Alien is phat/, "string op 2");
 like($output, qr/Resident has 8 letters, which is less than 10 and greater than 5/, "string length");
+like($output, qr/Multiple ors works/, 'multiple or test');
+like($output, qr/Addition and comparison 1/);
+unlike($output, qr/Addition and comparison 2/);
+like($output, qr/Addition and comparison 3/);
+unlike($output, qr/And 0 works/);
 
 $template = HTML::Template::Expr->new(path => ['t/templates'],
                                       filename => 'loop.tmpl',

Modified: trunk/libhtml-template-expr-perl/t/04register.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/04register.t?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/t/04register.t (original)
+++ trunk/libhtml-template-expr-perl/t/04register.t Wed Oct 14 16:04:50 2009
@@ -1,4 +1,4 @@
-use Test::More tests => 3;
+use Test::More tests => 4;
 use HTML::Template::Expr;
 
 HTML::Template::Expr->register_function(directory_exists => sub {
@@ -10,6 +10,7 @@
 					  1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
 					  return $_;
 					});
+HTML::Template::Expr->register_function(nada => sub { return });
 
 my $template = HTML::Template::Expr->new(path => ['t/templates'],
                                       filename => 'register.tmpl',
@@ -17,6 +18,7 @@
 my $output = $template->output;
 like $output, qr/^OK/, 'directory_exists()';
 like $output, qr/2,000/, 'comify';
+like $output, qr/nada worked/, 'nada worked';
 
 eval {
   HTML::Template::Expr->register_function('foo', 'bar');

Added: trunk/libhtml-template-expr-perl/t/05cache.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/05cache.t?rev=45796&op=file
==============================================================================
--- trunk/libhtml-template-expr-perl/t/05cache.t (added)
+++ trunk/libhtml-template-expr-perl/t/05cache.t Wed Oct 14 16:04:50 2009
@@ -1,0 +1,50 @@
+use Test::More tests => 15;
+use HTML::Template::Expr;
+use strict;
+
+my ($template, $output);
+
+# first load
+$template = HTML::Template::Expr->new(path => ['t/templates'],
+                                      filename => 'numerics.tmpl',
+				      cache => 1,
+				      cache_debug => 0,
+                                     );
+$template->param(float => 5.1,
+                 four => 4);
+$output = $template->output;
+like($output, qr/INT: 5/, "int()");
+like($output, qr/SQRT: 2/, "sqrt()");
+like($output, qr/SQRT2: 4/, "sqrt() 2");
+like($output, qr/SUM: 14/, "int(4 + 10.1)");
+like($output, qr/SPRINTF: 14.1000/, "sprintf('%0.4f', (10.1 + 4))");
+
+# load from cache
+$template = HTML::Template::Expr->new(path => ['t/templates'],
+                                      filename => 'numerics.tmpl',
+				      cache => 1,
+				      cache_debug => 0,
+                                     );
+$template->param(float => 5.1,
+                 four => 4);
+$output = $template->output;
+like($output, qr/INT: 5/, "int()");
+like($output, qr/SQRT: 2/, "sqrt()");
+like($output, qr/SQRT2: 4/, "sqrt() 2");
+like($output, qr/SUM: 14/, "int(4 + 10.1)");
+like($output, qr/SPRINTF: 14.1000/, "sprintf('%0.4f', (10.1 + 4))");
+
+# one more time...
+$template = HTML::Template::Expr->new(path => ['t/templates'],
+                                      filename => 'numerics.tmpl',
+				      cache => 1,
+				      cache_debug => 0,
+                                     );
+$template->param(float => 5.1,
+                 four => 4);
+$output = $template->output;
+like($output, qr/INT: 5/, "int()");
+like($output, qr/SQRT: 2/, "sqrt()");
+like($output, qr/SQRT2: 4/, "sqrt() 2");
+like($output, qr/SUM: 14/, "int(4 + 10.1)");
+like($output, qr/SPRINTF: 14.1000/, "sprintf('%0.4f', (10.1 + 4))");

Added: trunk/libhtml-template-expr-perl/t/06extra_attributes.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/06extra_attributes.t?rev=45796&op=file
==============================================================================
--- trunk/libhtml-template-expr-perl/t/06extra_attributes.t (added)
+++ trunk/libhtml-template-expr-perl/t/06extra_attributes.t Wed Oct 14 16:04:50 2009
@@ -1,0 +1,16 @@
+use Test::More qw(no_plan);
+use HTML::Template::Expr;
+
+my $template = HTML::Template::Expr->new(path => ['t/templates'],
+                                      filename => 'extra_attributes.tmpl',
+                                     );
+$template->param(who  => 'me & you',
+                 xss  => '<SCRIPT SRC="MALICIOUS.JS" />',
+                 back => 'http://google.com',
+                 js_string => "This is\n'me'",);
+my $output = $template->output();
+like($output, qr/ME &amp; YOU/);
+like($output, qr/&lt;script src=&quot;malicious\.js&quot; \/&gt;/);
+like($output, qr/Http%3A%2F%2Fgoogle\.com/);
+like($output, qr/this is\\n\\'me\\'/);
+

Modified: trunk/libhtml-template-expr-perl/t/templates/complex.tmpl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/templates/complex.tmpl?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/t/templates/complex.tmpl (original)
+++ trunk/libhtml-template-expr-perl/t/templates/complex.tmpl Wed Oct 14 16:04:50 2009
@@ -11,7 +11,28 @@
    Bar or Foo.
 </tmpl_if>
 
+<tmpl_if expr="bar || foo || bar || foo">
+   Multiple ors works
+</tmpl_if>
+
+<tmpl_if expr="(bar || foo || bar || foo) && bar">
+   And 0 works
+</tmpl_if>
+
+<tmpl_if expr="(foo + 1) < (foo + 2)">
+   Addition and comparison 1
+</tmpl_if>
+
+<tmpl_if expr="(foo + 1) > (foo + 2)">
+   Addition and comparison 2
+</tmpl_if>
+
+<tmpl_if expr="((foo + 1) > (foo + 2)) || ((foo + 1) < (foo + 2))">
+   Addition and comparison 3
+</tmpl_if>
+
 Bar - Foo = <tmpl_var expr="bar - foo">
+Foo - Bar + 10 = <tmpl_var expr="foo - bar + 10">
 
 <tmpl_if expr="((foo * foo) > (foo + foo))">
    Math Works, Alright

Added: trunk/libhtml-template-expr-perl/t/templates/extra_attributes.tmpl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/templates/extra_attributes.tmpl?rev=45796&op=file
==============================================================================
--- trunk/libhtml-template-expr-perl/t/templates/extra_attributes.tmpl (added)
+++ trunk/libhtml-template-expr-perl/t/templates/extra_attributes.tmpl Wed Oct 14 16:04:50 2009
@@ -1,0 +1,4 @@
+<tmpl_var expr="uc(who)" escape="HTML">
+<tmpl_var escape="HTML" expr="lc(xss)">
+<tmpl_var expr="ucfirst(back)" escape="URL">
+<tmpl_var expr="lcfirst(js_string)" escape="JS">

Modified: trunk/libhtml-template-expr-perl/t/templates/register.tmpl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhtml-template-expr-perl/t/templates/register.tmpl?rev=45796&op=diff
==============================================================================
--- trunk/libhtml-template-expr-perl/t/templates/register.tmpl (original)
+++ trunk/libhtml-template-expr-perl/t/templates/register.tmpl Wed Oct 14 16:04:50 2009
@@ -1,2 +1,3 @@
 <tmpl_if expr="directory_exists('t')">OK</tmpl_if>
 <tmpl_var expr="commify(2000)">
+<tmpl_unless expr="nada()">nada worked</tmpl_unless>




More information about the Pkg-perl-cvs-commits mailing list