Add all standard filters in v3

Thomas Wood
2016-02-05 15:52:25 +00:00
parent 39fc3e9bc5
commit 9c83ddc1c5
+13 -4
@@ -48,10 +48,16 @@ Hello {{ 'now' | date: "%Y %h" }}
* `last` - get the last element of the passed in array
* `join` - join elements of the array with certain character between them
* `sort` - sort elements of the array
* `reverse` - reverses the passed in array
* `map` - map/collect an array on a given property
* `size` - return the size of an array or string
* `escape` - escape a string
* `uniq` - removed duplicate elements from an array, optionally using a given property to test for uniqueness
* `escape` - html escape a string
* `escape_once` - returns an escaped version of html without affecting existing escaped entities
* `url_encode` - url encode a string
* `strip` - strips all whitespace from both ends of the string
* `lstrip` - strips all whitespace from the beginning of a string
* `rstrip` - strips all whitespace from the end of a string
* `strip_html` - strip html from string
* `strip_newlines` - strip all newlines (\n) from string
* `newline_to_br` - replace each newline (\n) with html break
@@ -65,14 +71,17 @@ Hello {{ 'now' | date: "%Y %h" }}
* `pluralize` - return the second word if the input is not `1`, otherwise return the first word *e.g.* `{{ 3 | pluralize: 'item', 'items' }} #=> 'items'`
* `append` - append a string *e.g.* `{{ 'foo' | append:'bar' }} #=> 'foobar'`
* `slice` - slice a string. Takes an offset and length, *e.g.* `{{ "hello" | slice: -3, 3 }} #=> llo`
* `split` - split a string on a matching pattern *e.g.* `{{ "a~b" | split:"~" }} #=> ['a','b']`
* `minus` - subtraction *e.g.* `{{ 4 | minus:2 }} #=> 2`
* `plus` - addition *e.g.* `{{ '1' | plus:'1' }} #=> 2`, `{{ 1 | plus:1 }} #=> 2`
* `times` - multiplication *e.g* `{{ 5 | times:4 }} #=> 20`
* `divided_by` - integer division *e.g.* `{{ 10 | divided_by:3 }} #=> 3`
* `round` - rounds input to the nearest integer or specified number of decimals
* `split` - split a string on a matching pattern *e.g.* `{{ "a~b" | split:"~" }} #=> ['a','b']`
* `modulo` - remainder, *e.g.* `{{ 3 | modulo:2 }} #=> 1`
* `reverse` - reverse sort the passed in array
* `round` - rounds input to the nearest integer or specified number of decimals *e.g.* `{{ 4.5612 | round: 2 }} #=> 4.56`
* `floor` - rounds a number down to the nearest integer, *e.g.* `{{ 4.6 | floor }} #=> 4`
* `ceil` - rounds a number up to the nearest integer, *e.g.* `{{ 4.6 | ceil }} #=> 5`
* `default` - returns the given variable unless it is null or the empty string, when it will return the given value, *e.g.* `{{ undefined_variable | default: "Default value" }} #=> "Default value"`
## Tags