mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 09:20:42 -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: {
|
||||
options: {
|
||||
map: true,
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ It can also be used with variables:
|
||||
{% highlight liquid %}
|
||||
{% raw %}
|
||||
{% assign filename = "/index.html" %}
|
||||
{{ product.url | append:filename }}
|
||||
{{ product.url | append: filename }}
|
||||
{% endraw %}
|
||||
# => "#{product.url}/index.html"
|
||||
{% endhighlight %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: capitalize
|
||||
---
|
||||
|
||||
`capitalize` ensures the first character of your string is capitalized.
|
||||
`capitalize` makes the first character of your string capitalized.
|
||||
|
||||
| Input | Output |
|
||||
|:-----------------------------------------------------------|:-----------------|
|
||||
|
||||
+3
-3
@@ -2,11 +2,11 @@
|
||||
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 %}
|
||||
{% raw %}
|
||||
{{ product_price | default:2.99 }}
|
||||
{{ product_price | default: 2.99 }}
|
||||
// => outputs "2.99"
|
||||
|
||||
{% assign product_price = 4.99 %}
|
||||
@@ -14,7 +14,7 @@ title: default
|
||||
// => outputs "4.99"
|
||||
|
||||
{% assign product_price = "" %}
|
||||
{{ product_price | default:2.99 }}
|
||||
{{ product_price | default: 2.99 }}
|
||||
// => outputs "2.99"
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
title: divided_by
|
||||
---
|
||||
|
||||
This filter divides its input by its parameter.
|
||||
This filter divides its input by its argument.
|
||||
|
||||
| Code | Output |
|
||||
|:--------------------------------------------------|:-------|
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
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 |
|
||||
|:-------------------------------------------------------|:-----------------|
|
||||
| {% 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
|
||||
---
|
||||
|
||||
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 |
|
||||
|:-------------------------------------------------------|:-------------------|
|
||||
| {% 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
|
||||
---
|
||||
|
||||
Performs a modulo operation (eg., fetches the remainder).
|
||||
Performs a modulo operation, i.e. returns the remainder.
|
||||
|
||||
| Code | Output |
|
||||
|:-------------------------------------------------------|:-------------------|
|
||||
| {% raw %}`{{ 2 | modulo: 2 }}`{% endraw %} | `1` |
|
||||
| {% raw %}`{{ 3 | modulo: 2 }}`{% endraw %} | `1` |
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
---
|
||||
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
|
||||
---
|
||||
|
||||
<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
|
||||
---
|
||||
|
||||
Removes any line breaks/newlines from a string.
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
---
|
||||
title: times
|
||||
---
|
||||
|
||||
Multiplies two numbers.
|
||||
|
||||
| Code | Output |
|
||||
|:-------------------------------------------------------|:-------------------|
|
||||
| {% raw %}`{{ 200 | times: 2 }}`{% endraw %} | `400` |
|
||||
|
||||
@@ -123,6 +123,7 @@ code {
|
||||
|
||||
pre {
|
||||
padding: 8px 12px;
|
||||
word-wrap: break-word;
|
||||
|
||||
> code {
|
||||
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.
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
---
|
||||
title: Iteration Tags
|
||||
title: Iteration
|
||||
---
|
||||
|
||||
# Iteration Tags
|
||||
|
||||
Iteration Tags are used to run a block of code repeatedly.
|
||||
|
||||
<a id="topofpage"></a>
|
||||
|
||||
+1
-8
@@ -1,14 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Theme Tags
|
||||
landing_as_article: true
|
||||
|
||||
nav:
|
||||
group: Liquid Documentation
|
||||
weight: 1
|
||||
title: Theme
|
||||
---
|
||||
|
||||
# Theme Tags
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user