The attached failing test case demonstrates a problem sorting a list
that contains one hash reference.
If you uncomment the additional hash reference, the list contains two
elements and the test passes. This problem only occurs with a one
element list.
I hope this provides enough information to diagnose the bug.
Thanks for all your great work on Template Toolkit.
Tom
Subject: | onesort.t |
#!perl
use strict;
use warnings;
package Foo;
sub new {
return bless {}, shift;
}
sub all {
return (
{
name => 'apple',
colour => 'green',
},
#{
# name => 'banana',
# colour => 'yellow',
#},
)
}
package main;
use Test::More tests => 1;
use Template ();
my $template = Template->new();
my $output;
$template->process(\*DATA, { foo => Foo->new() }, \$output)
or die $template->error;
like $output, qr/\bapple\b/;
__DATA__
[% FOREACH p IN foo.all.sort('name') -%]
A [% p.name %] is [% p.colour %]
[% END -%]