From 9c83ddc1c58d7b64d2b63700ef89bc42672f9099 Mon Sep 17 00:00:00 2001 From: Thomas Wood Date: Fri, 5 Feb 2016 15:52:25 +0000 Subject: [PATCH] Add all standard filters in v3 --- Liquid-for-Designers.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Liquid-for-Designers.md b/Liquid-for-Designers.md index f44e645..47cf3f6 100644 --- a/Liquid-for-Designers.md +++ b/Liquid-for-Designers.md @@ -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