The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/env perl -w
use strict;
use Test::More qw( no_plan );
use constant EXPECT_NUM => 4;
ok( my $t = Text::Template::Simple->new(), 'Got the object' );
ok( my $got = $t->compile(<<'THIS'), 'Compile' );
<% for (1..4) {%>
<%|- FILTER: foo;TEST-%>
<% } %>
THIS
my $expect = "!!!TEST!!!\n" x EXPECT_NUM;
is( $got, "$expect\n", 'Filtered block with loop around it' );
use strict;
sub filter_foo {
my $self = shift;
my $oref = shift;
${$oref} = sprintf "!!!%s!!!\n", ${$oref};
return;
}