Error
Numeric filters work with numbers to do some incredible things. For those that hate numbers you can convert them to pretty strings, for those that like them you can do all kinds of crazy math using them.
Returns the absolute or unsigned value of any input that can be converted to a number.
{% assign myNumber = '50' %} {% assign guess1 = 18 %} {% assign guess2 = 63 %} {% assign guess3 = 50.5 %} Guess My Number - Results Summary<br> Guess 1 was {{ myNumber | Minus:guess1 | Abs }} from the target number.<br> Guess 2 was {{ myNumber | Minus:guess2 | Abs }} from the target number.<br> Guess 3 was {{ myNumber | Minus:guess3 | Abs }} from the target number!<br>
Guess My Number - Results Summary Guess 1 was 32 from the target number. Guess 2 was 13 from the target number. Guess 3 was 0.5 from the target number!
Limits a number to a minimum value.
"Image": { "Width": 720, "Height": 480 }
<img src="..." style="width:{{ Image.Width | AtLeast:1080 }}px">
<img src="..." style="width:1080px">
Limits a number to a maximum value.
"Image": { "Width": 1920, "Height": 1080 }
<img src="..." style="height:{{ Image.Height | AtMost:720 }}px">
<img src="..." style="height:720px">
Takes a number and returns the next largest integer.
"Values": { "NumberOne": 2.6, "NumberTwo": 7.2 }
The next largest integer of {{ Values.NumberTwo }} is {{ Values.NumberTwo | Ceiling }}.
The next largest integer of 7.2 is 8.
Divides a number by the number provided.
"Values": { "InventoryTotal": 10000, "Quantity": 100 }
Each item costs ${{ Values.InventoryTotal | DividedBy:Values.Quantity }}.
Each item costs $100.
{{ 12.434 | DividedBy:6,2 }}
Takes a number and returns the next smallest integer.
The next smallest value of {{ Values.NumberOne }} is {{ Values.NumberOne | Floor }}.
The next smallest value of 2.6 is 2.
Formats the number based on a pattern you provide.
Takes a pattern or short code and formats the number accordingly. You can find a list of short codes at the .Net documentation site. You can also use patters like '#,##0.00' to format a number to have commas and two decimal places.
"Values": { "LastGift": "1200.23" }
Ted's last gift was for {{ 'Global' | Attribute:'CurrencySymbol' }}{{ Values.LastGift | Format:'#,##0.00' }}.
Ted's last gift was for $1,200.23.
Provides a simple way to display an internationalized currency amount. The filter uses the currency symbol defined in the 'OrganizationCurrencyCode' global attribute.
Ted's last gift was for {{ Values.LastGift | FormatAsCurrency }}.
Subtracts a number from the number provided.
"Values": { "RsvpMen": 10, "RSVPWomen": 2 }
There are {{ Values.RsvpMen | Minus:Values.RsvpWomen }} more men than women.
There are 8 more men than women.
The modulo filter returns the remainder of division of one number by another.
"Values": { "NumberOne": 7, "NumberTwo": 3 }
The remainder is {{ Values.NumberOne | Modulo:Values.NumberTwo }}.
The remainder is 1.
Takes 1, 2 or 3 and returns 1st, 2nd or 3rd.
"Values": { "RacerName": "Ted Decker", "Place": "2" }
{{ Values.RacerName }} came in {{ Values.Place | NumberToOrdinal }} place.
Ted Decker came in 2nd place.
Takes 1, 2 or 3 and returns first, second or third.
{{ Values.RacerName }} came in {{ Values.Place | NumberToOrdinalWords }} place.
Ted Decker came in second place.
For those Latin lovers, this filter takes a number and returns its Roman numeral equivalent.
"Values": { "Quantity": "26" }
Hodie vaccae lac {{ Values.Quantity | NumberToRomanNumerals }}.
Hodie vaccae lac XXVI.
Takes 1, 2 or 3 and returns one, two or three.
"Values": { "Quantity": "3" }
There are {{ Values.Quantity | NumberToWords }} units.
There are three units.
Adds a number to the number provided.
There are {{ Values.RsvpMen | Plus:Values.RsvpWomen }} coming to the event.
There are 12 coming to the event.
Generates a random number between 0 and up to (but not including) the number you pass in as input.
The random number is non-inclusive of the input value, meaning if you pass in 100 then you get a random number in the range of 0-99.
<p>The lottery number is {{ 100 | RandomNumber }}.</p>
<p>The lottery number is 83.</p>
Rounds a number to the nearest integer, or to a specified number of decimal places.
{{ 1.2 | Round }} {{ 2.7 | Round }} {{ 183.357 | Round: 2 }}
1 3 183.36
Multiplies a number by the number provided.
"Values": { "Cost": 10, "Quantity": 200 }
There are ${{ Values.Cost | Times:Values.Quantity }} worth of inventory.
There are $2000 worth of inventory.
Many times you want to call Singularize and Pluralize to prefix a word with a number; e.g. "2 requests", "3 men". ToQuantity prefixes the provided word with the number and accordingly pluralizes or singularizes the word.
"Person": { "PhoneNumbers": [ { "NumberFormatted": "(555) 555-5551" }, { "NumberFormatted": "(555) 555-5552" }, { "NumberFormatted": "(555) 555-5553" } ] }
{% assign phoneCount = Person.PhoneNumbers | Size %} Ted has {{ 'phone number' | ToQuantity:phoneCount }}.
Ted has 3 phone numbers.
Converts a number to a string.
"Pagination": { "NextPage": 2, "UrlTemplate": "/page/346?Page=PageNum" }
{% assign nextPageString = Pagination.NextPage | ToString %} <a href="{{ Pagination.UrlTemplate | Replace:'PageNum', nextPageString }}">Next</a>
<a href="/page/346?Page=2">Next</a>