diff --git a/lib/Template/Manual/VMethods.pod b/lib/Template/Manual/VMethods.pod index bb5b3cf6..17d08225 100644 --- a/lib/Template/Manual/VMethods.pod +++ b/lib/Template/Manual/VMethods.pod @@ -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 method modifies the list in place and +returns the list reference to allow chaining. When used standalone +(not chained), use the C 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 ]; diff --git a/t/vmethods/list.t b/t/vmethods/list.t index 0d590f2f..c51f1ed7 100644 --- a/t/vmethods/list.t +++ b/t/vmethods/list.t @@ -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 ]