String filters for manipulating text in Liquid templates.
append
append
can also be used with variables:
prepend
prepend
can also be used with variables:
capitalize
capitalize
only capitalizes the first character of a string, so later words are not affected:
upcase
downcase
strip
lstrip
rstrip
strip_newlines
replace
replace_first
replace_last
remove
remove_first
remove_last
truncate
truncate
takes an optional second argument that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (…), but you can specify a different sequence.
The length of the second argument counts against the number of characters specified by the first argument. For example, if you want to truncate a string to exactly 10 characters, and use a 3-character ellipsis, use 13 for the first argument of truncate
, since the ellipsis counts as 3 characters.
split
split
is commonly used to convert comma-separated items from a string to an array.
truncatewords
truncatewords
takes an optional second argument that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (…), but you can specify a different sequence.
normalize_whitespace
number_of_words
'cjk'
as the argument will count every CJK character detected as one word irrespective of being separated by whitespace.'auto'
(auto-detect) works similar to 'cjk'
but is more performant if the filter is used on a variable string that may or may not contain CJK chars.array_to_sentence_string