Liquid Filter Reference for slice - v0.9.5
Filter Name | slice |
Group | Arrays |
Version | 0.9.5 |
Description
Returns a substring of one character or series of array items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of array items to be returned.
Examples
{{ "Earthquake" | slice: 0 }}
E
{{ "Earthquake" | slice: 2 }}
r
{{ "Earthquake" | slice: 2, 5 }}
rthqu
Here the input value is an array:
{% assign an_array = "earth, water, air, fire" | split: ", " %}
{{ an_array | slice: 1, 2 }}
waterair
If the first argument is a negative number, the indices are counted from the end of the string:
{{ "Earthquake" | slice: -3, 2 }}
ak
Back to Liquid Reference for 0.9.5
Back to Documentation