Sisyphus repository
Last update: 2018-10-20 23:10:32 +0400 | SRPMs: 18821 | Sign in or Sign up
en ru uk br
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff -ur HTML-Template-Expr-0.07.orig/Expr.pm HTML-Template-Expr-0.07/Expr.pm
--- HTML-Template-Expr-0.07.orig/Expr.pm	2006-09-15 17:29:39 +0300
+++ HTML-Template-Expr-0.07/Expr.pm	2006-09-15 17:35:19 +0300
@@ -32,6 +32,7 @@
               | /le|ge|eq|ne|lt|gt/  { [ 'BIN_OP',  $item[1] ] }
               | /\|\||or|&&|and/     { [ 'BIN_OP',  $item[1] ] }
               | /[-+*\/%]/           { [ 'BIN_OP',  $item[1] ] }
+              | /=~|!~/              { [ 'BIN_OP',  $item[1] ] }
 
 function_call : function_name '(' args ')'  
                 { [ 'FUNCTION_CALL', $item[1], $item[3] ] }
@@ -305,6 +306,9 @@
           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; }
+          
+          if ($op eq '=~') {push @stack, $lhs =~ $rhs; next; }
+          if ($op eq '!~') {push @stack, $lhs !~ $rhs; next; }
 
           # short circuit or
           if ($op eq 'or' or $op eq '||') {
@@ -460,6 +464,9 @@
 
    <TMPL_VAR EXPR="sprintf('%d', foo)">
 
+Pattern in regular expression must be enclosed with "/":
+   <TMPL_VAR EXPR="foo =~ /bar/">
+
 You can string together operators to produce complex booleans:
 
   <TMPL_IF EXPR="(foo || bar || baz || (bif && bing) || (bananas > 10))">
@@ -549,6 +556,18 @@
 
 =back 4
 
+=head1 REGULAR EXPRESSION SUPPORT
+
+Standart regexp syntax:
+
+=over 4
+
+=item * =~
+
+=item * !~
+
+=back 4
+
 =head1 FUNCTIONS
 
 The following functions are available to be used in expressions.  See
@@ -697,9 +716,10 @@
 
 Thanks!
 
-=head1 AUTHOR
+=head1 AUTHORS
 
-Sam Tregar <sam@tregar.com>
+Sam Tregar <sam@tregar.com>, 
+Stanislav Yadykin <tosick at altlinux.ru> (regexp support)
 
 =head1 LICENSE
 
diff -ur HTML-Template-Expr-0.07.orig/t/01parse.t HTML-Template-Expr-0.07/t/01parse.t
--- HTML-Template-Expr-0.07.orig/t/01parse.t	2006-09-15 17:29:39 +0300
+++ HTML-Template-Expr-0.07/t/01parse.t	2006-09-15 17:36:21 +0300
@@ -30,6 +30,8 @@
              "(foo || bar || baz || bif)",
              "((foo || bar || baz) && bif)",
              "((foo || bar || baz) && (bif || 10))",
+             "(foo =~ /bar/)",
+             "(foo !~ /bar/)"
 	    );
 
 foreach my $test (@tests) {
 
© 2009–2018 Igor Zubkov