mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-28 22:55:12 -07:00
Adjust whitespace
This commit is contained in:
@@ -10,7 +10,6 @@ Liquid code can be categorized into [**objects**](#objects), [**tags**](#tags),
|
|||||||
|
|
||||||
**Objects** tell Liquid where to show content on a page. Objects and variable names are denoted by double curly braces: `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`.
|
**Objects** tell Liquid where to show content on a page. Objects and variable names are denoted by double curly braces: `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`.
|
||||||
|
|
||||||
|
|
||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
@@ -53,7 +52,6 @@ Tags can be categorized into three types:
|
|||||||
|
|
||||||
You can read more about each type of tag in their respective sections.
|
You can read more about each type of tag in their respective sections.
|
||||||
|
|
||||||
|
|
||||||
## Filters
|
## Filters
|
||||||
|
|
||||||
**Filters** change the output of a Liquid object. They are used within an output and are separated by a `|`.
|
**Filters** change the output of a Liquid object. They are used within an output and are separated by a `|`.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ Removes any `nil` values from an array.
|
|||||||
|
|
||||||
For this example, assume `site.pages` is an array of content pages for a website, and some of these pages have an attribute called `category` that specifies their content category. If we `map` those categories to an array, some of the array items might be `nil` if any pages do not have a `category` attribute.
|
For this example, assume `site.pages` is an array of content pages for a website, and some of these pages have an attribute called `category` that specifies their content category. If we `map` those categories to an array, some of the array items might be `nil` if any pages do not have a `category` attribute.
|
||||||
|
|
||||||
|
|
||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
{% raw %}
|
{% raw %}
|
||||||
```liquid
|
```liquid
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ You can also `prepend` variables:
|
|||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign url = "example.com" %}
|
{% assign url = "example.com" %}
|
||||||
|
|
||||||
{{ "/index.html" | prepend: url }}
|
{{ "/index.html" | prepend: url }}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
@@ -31,6 +30,5 @@ You can also `prepend` variables:
|
|||||||
<p class="code-label">Output</p>
|
<p class="code-label">Output</p>
|
||||||
```text
|
```text
|
||||||
{% assign url = "example.com" %}
|
{% assign url = "example.com" %}
|
||||||
|
|
||||||
{{ "/index.html" | prepend: url }}
|
{{ "/index.html" | prepend: url }}
|
||||||
```
|
```
|
||||||
|
|||||||
+4
-9
@@ -13,14 +13,14 @@ In this example, assume you have a list of products and you want to show your ki
|
|||||||
All products:
|
All products:
|
||||||
{% for product in products %}
|
{% for product in products %}
|
||||||
- {{ product.title }}
|
- {{ product.title }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% assign kitchen_products = products | where: "type", "kitchen" %}
|
{% assign kitchen_products = products | where: "type", "kitchen" %}
|
||||||
|
|
||||||
Kitchen products:
|
Kitchen products:
|
||||||
{% for product in kitchen_products %}
|
{% for product in kitchen_products %}
|
||||||
- {{ product.title }}
|
- {{ product.title }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
```
|
```
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
@@ -35,7 +35,6 @@ All products:
|
|||||||
Kitchen products:
|
Kitchen products:
|
||||||
- Spatula
|
- Spatula
|
||||||
- Garlic press
|
- Garlic press
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Say instead you have a list of products and you only want to show those that are available to buy. You can `where` with a property name but no target value to include all products with a [truthy]({{ "/basics/truthy-and-falsy#truthy" | prepend: site.baseurl }}) `"available"` value.
|
Say instead you have a list of products and you only want to show those that are available to buy. You can `where` with a property name but no target value to include all products with a [truthy]({{ "/basics/truthy-and-falsy#truthy" | prepend: site.baseurl }}) `"available"` value.
|
||||||
@@ -44,22 +43,20 @@ Say instead you have a list of products and you only want to show those that are
|
|||||||
{% raw %}
|
{% raw %}
|
||||||
```liquid
|
```liquid
|
||||||
All products:
|
All products:
|
||||||
{% for product in products %}
|
{% for product in products %}
|
||||||
- {{ product.title }}
|
- {{ product.title }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% assign available_products = products | where: "available" %}
|
{% assign available_products = products | where: "available" %}
|
||||||
|
|
||||||
Available products:
|
Available products:
|
||||||
{% for product in available_products %}
|
{% for product in available_products %}
|
||||||
- {{ product.title }}
|
- {{ product.title }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
```
|
```
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
<p class="code-label">Output</p>
|
<p class="code-label">Output</p>
|
||||||
|
|
||||||
```text
|
```text
|
||||||
All products:
|
All products:
|
||||||
- Coffee mug
|
- Coffee mug
|
||||||
@@ -69,10 +66,8 @@ All products:
|
|||||||
Available products:
|
Available products:
|
||||||
- Coffee mug
|
- Coffee mug
|
||||||
- Boring sneakers
|
- Boring sneakers
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
The `where` filter can also be used to find a single object in an array when combined with the `first` filter. For example, say you want to show off the shirt in your new fall collection.
|
The `where` filter can also be used to find a single object in an array when combined with the `first` filter. For example, say you want to show off the shirt in your new fall collection.
|
||||||
|
|
||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
|
|||||||
+5
-5
@@ -12,9 +12,9 @@ Repeatedly executes a block of code. For a full list of attributes available wit
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% for product in collection.products %}
|
{% for product in collection.products %}
|
||||||
{{ product.title }}
|
{{ product.title }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -196,8 +196,8 @@ one
|
|||||||
|
|
||||||
Uses for `cycle` include:
|
Uses for `cycle` include:
|
||||||
|
|
||||||
- applying odd/even classes to rows in a table
|
- applying odd/even classes to rows in a table
|
||||||
- applying a unique class to the last product thumbnail in a row
|
- applying a unique class to the last product thumbnail in a row
|
||||||
|
|
||||||
## cycle (parameters)
|
## cycle (parameters)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -21,7 +21,7 @@ Creates a new variable.
|
|||||||
|
|
||||||
<p class="code-label">Output</p>
|
<p class="code-label">Output</p>
|
||||||
```text
|
```text
|
||||||
This statement is valid.
|
This statement is valid.
|
||||||
```
|
```
|
||||||
|
|
||||||
Wrap a variable in quotations `"` to save it as a string.
|
Wrap a variable in quotations `"` to save it as a string.
|
||||||
@@ -55,6 +55,7 @@ Captures the string inside of the opening and closing tags and assigns it to a v
|
|||||||
```text
|
```text
|
||||||
I am being captured.
|
I am being captured.
|
||||||
```
|
```
|
||||||
|
|
||||||
Using `capture`, you can create complex strings using other variables created with `assign`.
|
Using `capture`, you can create complex strings using other variables created with `assign`.
|
||||||
|
|
||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user