-
Notifications
You must be signed in to change notification settings - Fork 0
Filter Reference
⚠️ ⚠️ THIS WIKI IS BEING USED TO JOT DOWN IDEAS AT PRESENT. DON'T ASSUME ANYTHING IS FIXED.⚠️ ⚠️
⚒️ MORE TO COME: Check back later
Filters take output piped to them from the left in a placeholder statement, process the data and pipe the output to the right. The first filter in a chain gets its input from the source element of the placeholder. The placeholder returns the output of last filter in the chain, if necessary converted to text.
Each filter takes data of one or more data types and output the data in (potentially) other data types.
Internally, filters are implemented as commands that take one parameter, the input, and return the output. For this reason any @
command that takes a sole parameter can also act as a filter.
Data types ending in "ish" mean that either the data type or a value that can be converted to the type are accepted. For example "numberish" means either a number or something else that is then converted to a number, say a text value or "1.5".
Note that all data types are "textish" because they can always be rendered as text. Whether that value is meaningful or not is another matter!
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 (based on the Liquid docs):
{{ -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 (from the Liquid docs):
{{ "/my/fancy/url" | append: ".html" }}
Outputs
/my/fancy/url.html
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 (from the Liquid docs):
{{ "Parker Moore" | downcase }}
{{ "apple" | downcase }}
Outputs
parker moore
apple
Swallows all its input and returns an empty string. Aimed for use with some special filters that create side affects where no output is required.
Input type: anything
Output type: null
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 (from the Liquid docs):
{{ "Parker Moore" | upcase }}
{{ "APPLE" | downcase }}
Outputs
PARKER MOORE
APPLE