Skip to content
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
9 changes: 6 additions & 3 deletions lib/Template/Manual/VMethods.pod
Original file line number Diff line number Diff line change
Expand Up @@ -606,16 +606,19 @@ command line utility).
=head2 import

Appends the contents of one or more other lists to the end of the
current list.
current list. The C<import> method modifies the list in place and
returns the list reference to allow chaining. When used standalone
(not chained), use the C<CALL> directive to suppress output of the
list reference.

[% one = [ 1 2 3 ];
two = [ 4 5 6 ];
three = [ 7 8 9 ];
one.import(two, three);
CALL one.import(two, three);
one.join(', '); # 1, 2, 3, 4, 5, 6, 7, 8, 9
%]

Import also allows chaining. The below syntax is equivalent.
Import also allows chaining:

[% one = [ 1 2 3 ];
two = [ 4 5 6 ];
Expand Down
19 changes: 19 additions & 0 deletions t/vmethods/list.t
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,25 @@ I want 1 kilos of Milk,



-- test --
-- name list import standalone CALL --
[% one = [ 1 2 3 ];
two = [ 4 5 6 ];
CALL one.import(two);
one.join(', ') %]
-- expect --
1, 2, 3, 4, 5, 6

-- test --
-- name list import standalone CALL multi --
[% one = [ 1 2 3 ];
two = [ 4 5 6 ];
three = [ 7 8 9 ];
CALL one.import(two, three);
one.join(', ') %]
-- expect --
1, 2, 3, 4, 5, 6, 7, 8, 9

-- test --
[% hash = { }
list = [ hash ]
Expand Down