Files
liquid/_filters/slice.md
2015-07-25 17:48:18 -04:00

839 B

title
title
slice

The slice filter returns a substring, starting at the specified index. An optional second parameter can be passed to specify the length of the substring. If no second parameter is given, a substring of one character will be returned.

Input Output
{% raw %}`{{ "hello" slice: 0 }}`{% endraw %}
{% raw %}`{{ "hello" slice: 1 }}`{% endraw %}
{% raw %}`{{ "hello" slice: 1, 3 }}`{% endraw %}

If the passed index is negative, it is counted from the end of the string.

Input Output
{% raw %}`{{ "hello" slice: -3, 2 }}`{% endraw %}