Number Filters These are provided in the default filters. Specifically, when TemplateOptions is constructed, these are added via the extension method WithNumberFilters. abs MethodNumberFilters.Abs Returns the absolute value – the distance from zero – for the input number. Liquid {{ -50 | abs }} {{ 50 | abs }} Output 50 50 at_least MethodNumberFilters.AtLeast Returns the greater of the input and first argument. The exact opposite of at_most. Liquid {{ 10 | at_least:20 }} {{ 30 | at_least:20 }} Output 20 30 at_most MethodNumberFilters.AtMost Returns the lesser of the input and first argument. The exact opposite of at_least. Liquid {{ 10 | at_most:20 }} {{ 30 | at_most:20 }} Output 10 20 ceil MethodNumberFilters.Ceil The input number, rounded up to the next integer. (Remember, a NumberValue is a decimal internally.) Liquid {{ 10.23 | ceil }} Output 11 divided_by MethodNumberFilters.DividedBy Divides the input by the argument. If the argument is an integer, the result is reduced to the nearest integer. (This is a duplicated quirk of the original Liquid.) Liquid {{ 10 | divided_by:2 }} {{ 10 | divided_by:3 }} Output 5 3 To get a decimal back (a non-rounded result), you need to pass in a decimal. Liquid {{ 10 | divided_by:3.0 }} Output 3.3333333333333333333333333333 floor MethodNumberFilters.Floor Reduces a decimal to the nearest smaller integer. (Note that NumberValue still wraps a decimal internally.) Liquid {{ 3.3 | floor }} Output 3 minus MethodNumberFilters.Minus Subtracts the first argument from the input. Liquid {{ 10 | minus:5 }} {{ 10.1 | minus:5.3 }} Output 5 4.8 modulo MethodNumberFilters.Modulo Divides the input by the first argument and returns the remainder. Both the input and the argument have to be integers (this isn’t a Liquid rule, this is a math rule). They will be converted to integers via Convert.ToInt32, so if you attempt to perform the operation on a decimal argument that converts to zero, you will get a “Attempted to divide by zero” error. Liquid {{ 10 | modulo:3 }} Output 1 (If you think you’ll be checking for multiples often, there’s an example of a custom ismultipleof operator in the chapter on conditionals). plus MethodNumberFilters.Plus Adds the input and the argument. Liquid {{ 10.1 | plus:5.3 }} Output 15.4 round MethodNumberFilters.Round Rounds the input. Values at .5 round up. Takes an optional parameter for the number of decimal places. Defaults to 0. Liquid {{ 1.1 | round }} {{ 1.49 | round }} {{ 1.5 | round }} {{ 1.617 | round:2 }} Output 1 1 2 1.62 times MethodNumberFilters.Times Multiples the input by the first argument. Liquid {{ 1.5 | times:2.5 }} Output 3.75