mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Added remainder of missing Filters
This commit is contained in:
@@ -1,3 +1,21 @@
|
|||||||
---
|
---
|
||||||
title: size
|
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>
|
||||||
|
|||||||
@@ -1,3 +1,23 @@
|
|||||||
---
|
---
|
||||||
title: sort
|
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>
|
||||||
|
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ title: uniq
|
|||||||
orange apple banana
|
orange apple banana
|
||||||
{% endraw %}{% endhighlight %}</div>
|
{% endraw %}{% endhighlight %}</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
---
|
---
|
||||||
title: url_encode
|
title: url_encode
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Converts any URL-unsafe characters in a string into percent-encoded characters.
|
||||||
|
|
||||||
|
| Code | Output |
|
||||||
|
|:-------------------------------------------------------|:-------------------|
|
||||||
|
| {% raw %}`{{ '[email protected]' | url_encode }}`{% endraw %} | `john%40liquid.com` |
|
||||||
|
|||||||
Reference in New Issue
Block a user