Added remainder of missing Filters

This commit is contained in:
Tetsuro
2015-10-15 13:16:36 -04:00
parent c744422d0e
commit 34def78926
4 changed files with 45 additions and 0 deletions

View File

@@ -1,3 +1,21 @@
---
title: size
---
<p>Returns the size of a string or an array.</p>
| 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.
<div>
{% highlight html %}{% raw %}
{% if collections.frontpage.products.size > 10 %}
There are more than 10 products in this collection!
{% endif %}
{% endraw %}{% endhighlight %}
</div>

View File

@@ -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.
<p class="input">Input</p>
<div>
{% highlight html %}{% raw %}
<!-- products = "a", "b", "A", "B" -->
{% assign products = collection.products | sort: 'title' %}
{% for product in products %}
{{ product.title }}
{% endfor %}{% endraw %}{% endhighlight %}
</div>
<p class="output">Output</p>
<div>
{% highlight html %}{% raw %}
A B a b
{% endraw %}{% endhighlight %}
</div>

View File

@@ -16,3 +16,4 @@ title: uniq
orange apple banana
{% endraw %}{% endhighlight %}</div>

View File

@@ -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` |