sprig icon indicating copy to clipboard operation
sprig copied to clipboard

List join functions (append / prepend but for multiple lists)

Open intelfx opened this issue 6 years ago • 1 comments

Issue-fied version of https://github.com/Masterminds/sprig/issues/3#issuecomment-349094450:

Since append is not variadic, is there a method to concatenate two arrays/slices? This would be nice: {{ range (append .arrayA .arrayB) }}

Specifically, this feature request is to add two new (variadic, as per #3) functions:

  • $newList = appendlist $myList $otherList $yetAnotherList
  • $newList = prependlist $myList $otherList $yetAnotherList

Since join is taken, if appendlist / prependlist are deemed too long & unwieldy, I alternatively propose to name them cat and tac in recognition of eponymous POSIX command-line tools.

intelfx avatar Feb 22 '19 08:02 intelfx

concat has already been added to combine lists.

prepending would be a feature request.

mattfarina avatar Sep 30 '19 17:09 mattfarina