From 34def78926193de806e63ba4520a5f3ce2ecf7b6 Mon Sep 17 00:00:00 2001 From: Tetsuro Date: Thu, 15 Oct 2015 13:16:36 -0400 Subject: [PATCH] Added remainder of missing Filters --- _filters/size.md | 18 ++++++++++++++++++ _filters/sort.md | 20 ++++++++++++++++++++ _filters/uniq.md | 1 + _filters/url_encode.md | 6 ++++++ 4 files changed, 45 insertions(+) diff --git a/_filters/size.md b/_filters/size.md index 52d97ca..7711f14 100644 --- a/_filters/size.md +++ b/_filters/size.md @@ -1,3 +1,21 @@ --- title: size --- + +

Returns the size of a string or an array.

+ + +| Code | Output | +|:-------------------------------------------------------|:-------------------| +| {% raw %}`{{ 'is this a 30 character string?' | size }}`{% endraw %} | `30` | + + +`size` can be used in dot notation, in cases where it needs to be used inside a tag. + +
+{% highlight html %}{% raw %} +{% if collections.frontpage.products.size > 10 %} + There are more than 10 products in this collection! +{% endif %} +{% endraw %}{% endhighlight %} +
diff --git a/_filters/sort.md b/_filters/sort.md index 1e5011c..c6805f2 100644 --- a/_filters/sort.md +++ b/_filters/sort.md @@ -1,3 +1,23 @@ --- title: sort --- + +Sorts items in an array by a property of an item in the array. The order of the sorted array is case-sensitive. + +

Input

+
+{% highlight html %}{% raw %} + +{% assign products = collection.products | sort: 'title' %} +{% for product in products %} + {{ product.title }} +{% endfor %}{% endraw %}{% endhighlight %} +
+ +

Output

+
+{% highlight html %}{% raw %} +A B a b +{% endraw %}{% endhighlight %} +
+ diff --git a/_filters/uniq.md b/_filters/uniq.md index 7ce25a6..84b7703 100644 --- a/_filters/uniq.md +++ b/_filters/uniq.md @@ -16,3 +16,4 @@ title: uniq orange apple banana {% endraw %}{% endhighlight %} + diff --git a/_filters/url_encode.md b/_filters/url_encode.md index 133ff80..989a795 100644 --- a/_filters/url_encode.md +++ b/_filters/url_encode.md @@ -1,3 +1,9 @@ --- title: url_encode --- + +Converts any URL-unsafe characters in a string into percent-encoded characters. + +| Code | Output | +|:-------------------------------------------------------|:-------------------| +| {% raw %}`{{ 'john@liquid.com' | url_encode }}`{% endraw %} | `john%40liquid.com` |