Introduction

The slice filter is used to extract a portion of a string, array, or other sequence type. It allows you to select a subset of elements or characters by specifying the starting point and the number of elements you want to extract.

Example of Use

Example of how to use the slice filter to get the first three characters of a string:
{% set text = 'Reportana' %}
{% set sliced_text = text|slice(0, 3) %}
{{ sliced_text }}

Output Example of the Code

Result of `slice` Filter