use strict;
use base qw(Squirrel::Template::Expr::WrapBase);
use Scalar::Util ();
+use List::Util ();
-our $VERSION = "1.006";
+our $VERSION = "1.007";
my $list_make_key = sub {
my ($item, $field) = @_;
return [ reverse @{$self->[0]} ];
}
+sub _do_shuffle {
+ my ($self, $args) = @_;
+
+ @$args == 0
+ or die [ error => "list.shuffle takes no parameters" ];
+
+ return [ List::Util::shuffle(@{$self->[0]}) ];
+}
+
sub _do_join {
my ($self, $args) = @_;
#!perl -w
# Basic tests for Squirrel::Template
use strict;
-use Test::More tests => 184;
+use Test::More tests => 185;
use HTML::Entities;
sub template_test($$$$;$$);
[ '[ [ 1, 2 ], 3 ].expand.join(",")', "1,2,3" ],
[ '[ 1, 2 ].is_list', 1 ],
[ '[ 1, 2 ].is_hash', 0 ],
+ [ '[ 1 .. 5 ].shuffle.size', 5 ],
# WrapHash
[ '{ "foo": 1 }.is_list', 0 ],