mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-27 06:05:11 -07:00
Added a bunch of missing filters, made some of the copy more consistent
This commit is contained in:
@@ -43,7 +43,6 @@ require('load-grunt-tasks')(grunt);
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
postcss: {
|
postcss: {
|
||||||
options: {
|
options: {
|
||||||
map: true,
|
map: true,
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ It can also be used with variables:
|
|||||||
{% highlight liquid %}
|
{% highlight liquid %}
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign filename = "/index.html" %}
|
{% assign filename = "/index.html" %}
|
||||||
{{ product.url | append:filename }}
|
{{ product.url | append: filename }}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
# => "#{product.url}/index.html"
|
# => "#{product.url}/index.html"
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
title: capitalize
|
title: capitalize
|
||||||
---
|
---
|
||||||
|
|
||||||
`capitalize` ensures the first character of your string is capitalized.
|
`capitalize` makes the first character of your string capitalized.
|
||||||
|
|
||||||
| Input | Output |
|
| Input | Output |
|
||||||
|:-----------------------------------------------------------|:-----------------|
|
|:-----------------------------------------------------------|:-----------------|
|
||||||
|
|||||||
+3
-3
@@ -2,11 +2,11 @@
|
|||||||
title: default
|
title: default
|
||||||
---
|
---
|
||||||
|
|
||||||
`default` offers a means of having a fall-back value in case your value doesn't exist.
|
`default` offers a means of having a fallback in case your value doesn't exist.
|
||||||
|
|
||||||
{% highlight liquid %}
|
{% highlight liquid %}
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{{ product_price | default:2.99 }}
|
{{ product_price | default: 2.99 }}
|
||||||
// => outputs "2.99"
|
// => outputs "2.99"
|
||||||
|
|
||||||
{% assign product_price = 4.99 %}
|
{% assign product_price = 4.99 %}
|
||||||
@@ -14,7 +14,7 @@ title: default
|
|||||||
// => outputs "4.99"
|
// => outputs "4.99"
|
||||||
|
|
||||||
{% assign product_price = "" %}
|
{% assign product_price = "" %}
|
||||||
{{ product_price | default:2.99 }}
|
{{ product_price | default: 2.99 }}
|
||||||
// => outputs "2.99"
|
// => outputs "2.99"
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
title: divided_by
|
title: divided_by
|
||||||
---
|
---
|
||||||
|
|
||||||
This filter divides its input by its parameter.
|
This filter divides its input by its argument.
|
||||||
|
|
||||||
| Code | Output |
|
| Code | Output |
|
||||||
|:--------------------------------------------------|:-------|
|
|:--------------------------------------------------|:-------|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
title: downcase
|
title: downcase
|
||||||
---
|
---
|
||||||
|
|
||||||
This filter makes the entire input string the lower case version of each character within.
|
`downcase` makes each character in a string lowercase.
|
||||||
|
|
||||||
| Code | Output |
|
| Code | Output |
|
||||||
|:-------------------------------------------------------|:-----------------|
|
|:-------------------------------------------------------|:-----------------|
|
||||||
| {% raw %}`{{ "Peter Parker" | downcase }}`{% endraw %} | `"peter parker"` |
|
| {% raw %}`{{ "Peter Parker" | downcase }}`{% endraw %} | `"peter parker"` |
|
||||||
|
|
||||||
It doesn't modify strings which are already entirely lowercase. It works with anything that has a `#to_s` method.
|
It doesn't modify strings which are already entirely lowercase.
|
||||||
|
|||||||
+1
-2
@@ -2,10 +2,9 @@
|
|||||||
title: first
|
title: first
|
||||||
---
|
---
|
||||||
|
|
||||||
Return the first element of an array.
|
Returns the first element of an array. For example, if you have an array called `product.tags` that resolves to: `["sale", "mens", "womens", "awesome"]`:
|
||||||
|
|
||||||
| Code | Output |
|
| Code | Output |
|
||||||
|:-------------------------------------------------------|:-------------------|
|
|:-------------------------------------------------------|:-------------------|
|
||||||
| {% raw %}`{{ product.tags | first }}`{% endraw %} | `"sale"` |
|
| {% raw %}`{{ product.tags | first }}`{% endraw %} | `"sale"` |
|
||||||
|
|
||||||
In the sample above, assume that `product.tags` resolves to: `["sale", "mens", "womens", "awesome"]`.
|
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
title: modulo
|
title: modulo
|
||||||
---
|
---
|
||||||
|
|
||||||
Performs a modulo operation (eg., fetches the remainder).
|
Performs a modulo operation, i.e. returns the remainder.
|
||||||
|
|
||||||
| Code | Output |
|
| Code | Output |
|
||||||
|:-------------------------------------------------------|:-------------------|
|
|:-------------------------------------------------------|:-------------------|
|
||||||
| {% raw %}`{{ 2 | modulo: 2 }}`{% endraw %} | `1` |
|
| {% raw %}`{{ 3 | modulo: 2 }}`{% endraw %} | `1` |
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
---
|
---
|
||||||
title: reverse
|
title: reverse
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Reverses the order of an array.
|
||||||
|
|
||||||
|
{% highlight liquid %}
|
||||||
|
{% raw %}
|
||||||
|
{{ product.tags }}
|
||||||
|
// ['cool', 'sale', 'purple', 'awesome']
|
||||||
|
|
||||||
|
{{ product.tags | reverse }}
|
||||||
|
// ['awesome', 'purple', 'sale', 'cool']
|
||||||
|
{% endraw %}
|
||||||
|
{% endhighlight %}
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
---
|
---
|
||||||
title: strip_html
|
title: strip_html
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<p>Strips all HTML tags from a string.</p>
|
||||||
|
|
||||||
|
<p class="input">Input</p>
|
||||||
|
|
||||||
|
| Code | Output |
|
||||||
|
|:-------------------------------------------------------|:-------------------|
|
||||||
|
| {% raw %}`{{ "<h1>Hello</h1> World" | strip_html }}`{% endraw %} | `Hello World` |
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: strip_newlines
|
title: strip_newlines
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Removes any line breaks/newlines from a string.
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
---
|
---
|
||||||
title: times
|
title: times
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Multiplies two numbers.
|
||||||
|
|
||||||
|
| Code | Output |
|
||||||
|
|:-------------------------------------------------------|:-------------------|
|
||||||
|
| {% raw %}`{{ 200 | times: 2 }}`{% endraw %} | `400` |
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ code {
|
|||||||
|
|
||||||
pre {
|
pre {
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
|
||||||
> code {
|
> code {
|
||||||
border: 0;
|
border: 0;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Control Flow Tags
|
title: Control Flow
|
||||||
---
|
---
|
||||||
|
|
||||||
# Control Flow Tags
|
|
||||||
|
|
||||||
Control Flow tags determine which block of code should be executed based on different conditions.
|
Control Flow tags determine which block of code should be executed based on different conditions.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Iteration Tags
|
title: Iteration
|
||||||
---
|
---
|
||||||
|
|
||||||
# Iteration Tags
|
|
||||||
|
|
||||||
Iteration Tags are used to run a block of code repeatedly.
|
Iteration Tags are used to run a block of code repeatedly.
|
||||||
|
|
||||||
<a id="topofpage"></a>
|
<a id="topofpage"></a>
|
||||||
|
|||||||
+1
-8
@@ -1,14 +1,7 @@
|
|||||||
---
|
---
|
||||||
layout: default
|
title: Theme
|
||||||
title: Theme Tags
|
|
||||||
landing_as_article: true
|
|
||||||
|
|
||||||
nav:
|
|
||||||
group: Liquid Documentation
|
|
||||||
weight: 1
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Theme Tags
|
|
||||||
|
|
||||||
Theme Tags have various functions, including:
|
Theme Tags have various functions, including:
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
---
|
---
|
||||||
title: Variable Tags
|
title: Variable
|
||||||
---
|
---
|
||||||
|
|
||||||
# Variable Tags
|
|
||||||
|
|
||||||
Variable Tags are used to create new Liquid variables.
|
Variable Tags are used to create new Liquid variables.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user