mirror of
https://github.com/kemko/liquid.git
synced 2026-01-05 17:55:40 +03:00
839 B
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 %} |