Subject: | Filters affect implicit SET directive |
I'm not sure if there is a reasonable way around this, but in TT: '[% x
= [ 1, 2 ] | html %]' does not set to an array, but instead to
"ARRAY(0x21636d0)".
In a normal TT template, this is not really an issue an issue since one
does not attempt to filter such things, however with an AutoFilter, this
came up fairly quickly for me. I can not use '[% x = [ 1, 2 ] %]', I
must instead use '[% SET x = [ 1, 2 ] %]'. This applies to hard-coded
references as well as references returned by method or subroutine calls.
This can make migration to Template::AutoFilter harder than one might
like it to be.
Test script attached illustrating desired behaviors.
Template version: 2.22
Template::AutoFilter version: 0.112120
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 6;
use Template;
use Template::AutoFilter;
my $templ_1 = "[% x = [ 1, 2 ] %] [% x.join(', ') %]";
my $templ_2 = "[% x = [ 1, 2 ] | html %] [% x.join(', ') | html %]";
my $templ_3 = "[% SET x = [ 1, 2 ] %] [% x.join(', ') %]";
my $wanted = " 1, 2";
for ($templ_1, $templ_2, $templ_3) {
my $out;
Template::AutoFilter->new->process( \$_, { }, \$out );
is( $out, $wanted );
}
for ($templ_1, $templ_2, $templ_3) {
my $out;
Template->new->process( \$_, { }, \$out );
is( $out, $wanted );
}