All filters
Grouped by functionality.
This is a based info on the CloudCannon Jekyll cheatsheet. See also Liquid filters on Jekyll docs.
The items here are grouped and ordered by use, rather than alpabetically.
For escaping a URI:
url_escape
cgi_escape
For escaping HTML tags:
xml_escape
escape
escape_once
See also the Arrays cheatsheet.
String filters
-
append
-
prepend
-
slice
Get items in an iterable from start index (inclusive) for a limit of items. See also
slice
in Array section and belowoffset
andlimit
in the For loops page. -
markdownify
-
jsonify
-
inspect
Show a value as a Ruby object. Useful for debugging. Especially useful if a value is possibly null and therefore invisible or if you have a data structure to understand.
-
date
-
default
-
replace
Warning - if you do
replace
on an array, it converts it to a string. -
replace_first
-
strip
-
lstrip
-
rstrip
-
capitalize
-
downcase
-
upcase
-
split
-
truncate
Truncate a string down to x characters
-
truncatewords
Truncate a string down to x words
-
strip_html
-
strip_newlines
Remove
\n
characters -
newline_to_br
Convert
\n
to twobr
tags -
escape
Escape HTML so that tags appear as ampersand charactes that aren’t evaluated
-
uri_escape
Escape a URI with percent coding
-
url_decode
-
url_encode
-
slugify
Array filters
-
join
-
first
-
last
-
concat
Combine to arrays - parameter must be of type array to avoid error
-
slice
Get an item by index. Or with two values as a range, set a start index and a count of elements. See also
offset
andlimit
on the For loops page. -
map
-
where
A simple filter where an attribute value matches a given value.
-
where_exp
A filter where a given expression is true.
-
group_by
Group an array’s items by a given property. You’ll get a hash where that attribute is used as the key and the value is all the match items (the attribute is not removed).
-
group_by_exp
-
size
-
reverse
-
sort
-
sort_natural
Sorts items in an array in case-insensitive order
-
uniq
You don’t have to sort, but if you do then your results will read better.
-
push
Insert at the end of the array
-
pop
Remove an item from the end of an array. Accepts optional param
num
which defaults to1
-
unshift
Insert at the start of the array
-
shift
Remove an item from the start of an array. Accepts optional param
num
which defaults to1
-
compact
Removes any nil values from an array.
Maths
-
plus
-
minus
-
times
-
divided_by
-
modulo
-
floor
-
ceil
-
round
-
abs
-
at_least
Limits a number to a minimum value. Same as
min(a, b)
in other languages. -
at_most
Limits a number to a maximum value. Same as
max(a, b)
in other languages.