Skip to content
Log in

slice - Liquid Filter Reference

On this page

Description

Returns a substring of one character or series of list items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of list items to be returned.

Property Value
Return Type any
Category general

Examples

liquid {{ "Earthquake" | slice: 0 }}

Output: E

liquid {{ "Earthquake" | slice: 2 }}

Output: r

liquid {{ "Earthquake" | slice: 2, 5 }}

Output: rthqu

Here the input value is an list

liquid {{ an_list | slice: 1, 2 }}

Output: waterair

If the first argument is a negative number, the indices are counted from the end of the string

liquid {{ "Earthquake" | slice: -3, 2 }}

Output: ak

Was this article helpful?

Was this article helpful?