Subject: | Methods returning single element lists of hashrefs are broken. |
Take the following program, the sub passed in to Template::Toolkit returns a list containing one hashref. All the calls to this sub are reporting just the hashref, ignoring the list. A hack showing the expected output is at the bottom by abusing a matching all grep, a double reverse would also suffice.
#!/usr/bin/env perl
use strict;
use warnings;
use Template;
sub sub {
my @array = {qw/foo bar baz qux/};
return @array;
}
Template->new->process(\<<'EOF', { sub => \&sub } );
[% sub %]
[% sub.size %]
[% FOR val IN sub %]
[% val %]
[% END %]
[% FOR val IN sub.grep('') %]
[% val %]
[% END %]
EOF