Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return empty string from list import. #74

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#
#========================================================================

* Matthew Somerville stopped a list import from printing an ARRAY(...) string.
https://github.com/abw/Template2/issues/33


#-----------------------------------------------------------------------
# Version 2.27 - 13th December 2016
#------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/Template/Manual/VMethods.pod
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ current list.
two = [ 4 5 6 ];
three = [ 7 8 9 ];
one.import(two, three);
one.join(', ); # 1, 2, 3, 4, 5, 6, 7, 8, 9
one.join(', '); # 1, 2, 3, 4, 5, 6, 7, 8, 9
%]

=head2 merge
Expand Down
2 changes: 1 addition & 1 deletion lib/Template/VMethods.pm
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ sub list_unique {
sub list_import {
my $list = shift;
push(@$list, grep defined, map ref eq 'ARRAY' ? @$_ : undef, @_);
return $list;
return '';
}

sub list_merge {
Expand Down
6 changes: 4 additions & 2 deletions t/vmethods/list.t
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ Tom
-- name list import one --
[% list_one = [ 1 2 3 ];
list_two = [ 4 5 6 ];
list_one.import(list_two).join(', ') %]
list_one.import(list_two);
list_one.join(', ') %]
-- expect --
1, 2, 3, 4, 5, 6

Expand All @@ -295,7 +296,8 @@ Tom
[% list_one = [ 1 2 3 ];
list_two = [ 4 5 6 ];
list_three = [ 7 8 9 0 ];
list_one.import(list_two, list_three).join(', ') %]
list_one.import(list_two, list_three);
list_one.join(', ') %]
-- expect --
1, 2, 3, 4, 5, 6, 7, 8, 9, 0

Expand Down