Lava Filters - Slice (arrays)

Category:Arrays

Description:The slice filter (when used on an array) returns a subset of the given array, starting at the specified index. An optional second parameter can be passed to specify the length of the subset. If no second parameter is given, a subset of one item will be returned.
Input: "List": [ 1, 2, 3, 4, 5 ]
Lava: {% assign sublist = List | Slice:2,3 %}
    {% for i in sublist %}
  • {{ i }}
  • {% endfor %}
Output:
  • 2
  • 3
  • 4