Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

cease warnings in replace vmethod #9

Merged
merged 1 commit into from

2 participants

This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.