-
Notifications
You must be signed in to change notification settings - Fork 0
Liquid Filters
⚠️ ⚠️ THIS WIKI IS BEING USED TO JOT DOWN IDEAS AT PRESENT. DON'T ASSUME ANYTHING IS FIXED.⚠️ ⚠️
⚒️ MORE TO COME: Check back later
The filters listed on this page are based on, and have similar syntax and purpose to, Liquid filters.
Not all liquid filters will necessarily be implemented. Those filters listed here that are not yet implemented are marked with a ⛔ symbol.
The examples included with many of the filters are copied from the Liquid documentation.
A link to the original Liquid documentation is included with each filter.
⛔ Returns the absolute value of a numberish value provided on its input. If the input is not numberish then an error is reported.
Parameters: none
Input type: numberish
Output type: Number (Int if input was, or was converted to, Int or Float if input was, or was converted to, Float)
Example:
{{ -17 | abs }}
{{ -56.42 }}
{{ 4 | abs }}
{{ "42" | abs }}
Outputs
17
56.42
4
42
⛔ Appends the text given as a parameter to the input and returns the result.
Parameter: text to be appended, type textish.
Input type: textish
Output type: text
Example:
{{ "/my/fancy/url" | append: ".html" }}
Outputs
/my/fancy/url.html
⛔ Rounds an input Float up to the nearest whole number.
Parameter: none.
Input type: Floatish
Output type: Int
Example:
{{ 1.2 | ceil }}
{{ 2.0 | ceil }}
{{ 183.357 | ceil }}
Outputs:
2
2
184
⛔ Formats a DateTime as a Text value according to the format string passed as a parameter. The format string has the same syntax as strftime.
Parameter: date formatting string, type Text.
Input type: DateTime
Output type: Text
Example (assuming @now
is returning 2015-07-17
):
{{ @now | date: "%a, %b %d, %y" }}
{{ @now | date: "%Y" }}
Outputs:
Fri, Jul 17, 15
2015
⛔ Divides the number on the input by the number passed as a parameter.
The result is of the same type as the divisor (i.e. the parameter). So if the divisor is an integer then the result will be rounded down to the nearest integer. In the case where the divisor is floating point then the result will also be floating point, with no rounding.
Parameter: the divisor (must not be 0), type Int or Float
Input type: Int or Float
Output type: Int or Float (same as parameter)
Example:
{{ 20 | divided_by: 7 }}
{{ 20 | divided_by: 7.0 }}
{{ 25.5 | divided_by: 8 }}
{{ 25.5 | divided_by: 8.7 }}
Outputs
2
2.8571428571
3
2.9310344828
Notes:
-
To force floating point division when the parameter is an integer use an embedded placeholder with the rpt
int-to-float
filter, as follows:{{ 20 | divided_by: {{ 7 | int-to-float }} }}
-
Dividing a floating point value by an integer is equivalent to doing a floating point division and taking the floor of the result. So the following two placeholders will return the same result:
{{ 42.5 | divided_by: 7 }} {{ 42.5 | divided_by: 7.0 | floor }}
-
See also the less complicated rpt
div
(integer division) anddivide
(floating point division) filters.
⛔ Converts each character of text from the input into lower case.
Any type other than text is first converted to text and then processed.
Parameters: none
Input type: Textish
Output type: Text
Example:
{{ "Parker Moore" | downcase }}
{{ "apple" | downcase }}
Outputs
parker moore
apple
⛔ Rounds an input Float down to the nearest whole number.
Parameter: none.
Input type: Floatish
Output type: Int
Example:
{{ 1.2 | floor }}
{{ 2.0 | floor }}
{{ 183.357 | floor }}
Outputs:
1
2
183
⛔ Subtracts the number given as a parameter from the input number and outputs the result.
Parameter: number to be subtracted from input, type Numeric.
Input type: Numeric
Output type: Int if both the input and parameter are Int, otherwise Float.
Example:
{{ 4 | minus: 2 }}
{{ 16.9 | minus: 4.2 }}
{{ 183.357 | minus: 12 }}
Outputs
2
12.7
171.357
⛔ Adds the number given as a parameter to the input number and outputs the result.
Parameter: number to be added to input, type Numeric.
Input type: Numeric
Output type: Int if both the input and parameter are Int, otherwise Float.
Example:
{{ 4 | plus: 2 }}
{{ 16.0 | plus: 4.2 }}
{{ 183.357 | plus: 12 }}
Outputs
6
20.2
195.357
⛔ Prepends the text given as a parameter to the input and returns the result.
Parameter: text to be prepended, type textish.
Input type: textish
Output type: text
Example:
{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
Outputs
Some fruit: apples, oranges, and bananas
⛔ Rounds an input Float off to the nearest whole number or, if an argument is provided, to the specified number of decimal places.
Parameter: number of decimal places to round to (optional: default is 0), Type Int.
Input type: Floatish
Output type: Int
Example:
{{ 1.2 | round }}
{{ 2.7 | round }}
{{ 183.357 | round: 2 }}
Output:
1
3
183.36
⛔ Multiplies the number given as a parameter by the input number and outputs the result.
Parameter: number to be multiplied by input, type Numeric.
Input type: Numeric
Output type: Int if both the input and parameter are Int, otherwise Float.
Example:
{{ 3 | times: 2 }}
{{ 24.7 | times: 7.3 }}
{{ 183.357 | times: 12 }}
Outputs
6
180.31
2200.284
⛔ Converts each character of text from the input into upper case.
Any type other than text is first converted to text and then processed.
Parameters: none
Input type: Textish
Output type: Text
Example:
{{ "Parker Moore" | upcase }}
{{ "APPLE" | upcase }}
Outputs
PARKER MOORE
APPLE