Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from eserte/replace-warnings

cease warnings in replace vmethod
  • Loading branch information...
commit 8d97c6d101035b4d0228de42f4bf011927ac0671 2 parents fde062c + 3fe5f0d
@abw authored
Showing with 8 additions and 2 deletions.
  1. +1 −1  lib/Template/VMethods.pm
  2. +7 −1 t/vmethods/replace.t
View
2  lib/Template/VMethods.pm
@@ -220,7 +220,7 @@ sub text_replace {
my ($chunk, $start, $end) = @_;
$chunk =~ s{ \\(\\|\$) | \$ (\d+) }{
$1 ? $1
- : ($2 > $#$start || $2 == 0) ? ''
+ : ($2 > $#$start || $2 == 0 || !defined $start->[$2]) ? ''
: substr($text, $start->[$2], $end->[$2] - $start->[$2]);
}exg;
$chunk;
View
8 t/vmethods/replace.t
@@ -200,4 +200,10 @@ oo\$1 bar
-- expect --
f!! ba!r! f!!ba!r!
-
+-- test --
+-- name: no warnings --
+[% text = 'foo';
+ text.replace('(optional)?(foo)', '$1$2');
+%]
+-- expect --
+foo
Please sign in to comment.
Something went wrong with that request. Please try again.