mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 03:10:39 -07:00
Prefer double quotes for strings
This commit is contained in:
@@ -70,7 +70,7 @@ You can use multiple operators in a tag:
|
|||||||
|
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% if product.title contains 'Pack' %}
|
{% if product.title contains "Pack" %}
|
||||||
This product's title contains the word Pack.
|
This product's title contains the word Pack.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -80,8 +80,8 @@ You can use multiple operators in a tag:
|
|||||||
|
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% if product.tags contains 'Hello' %}
|
{% if product.tags contains "Hello" %}
|
||||||
This product has been tagged with 'Hello'.
|
This product has been tagged with "Hello".
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
@@ -95,7 +95,7 @@ In tags with more than one `and` or `or` operator, operators are checked in orde
|
|||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% if true or false and false %}
|
{% if true or false and false %}
|
||||||
This evaluates to true, since the 'and' condition is checked first.
|
This evaluates to true, since the `and` condition is checked first.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ For this example, assume `site.pages` is an array of content pages for a website
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign site_categories = site.pages | map: 'category' %}
|
{% assign site_categories = site.pages | map: "category" %}
|
||||||
|
|
||||||
{% for category in site_categories %}
|
{% for category in site_categories %}
|
||||||
- {{ category }}
|
- {{ category }}
|
||||||
@@ -34,7 +34,7 @@ By using `compact` when we create our `site_categories` array, we can remove all
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign site_categories = site.pages | map: 'category' | compact %}
|
{% assign site_categories = site.pages | map: "category" | compact %}
|
||||||
|
|
||||||
{% for category in site_categories %}
|
{% for category in site_categories %}
|
||||||
- {{ category }}
|
- {{ category }}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Executes a block of code only if a certain condition is `true`.
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% if product.title == 'Awesome Shoes' %}
|
{% if product.title == "Awesome Shoes" %}
|
||||||
These shoes are awesome!
|
These shoes are awesome!
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -31,7 +31,7 @@ The opposite of `if` – executes a block of code only if a certain condition is
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% unless product.title == 'Awesome Shoes' %}
|
{% unless product.title == "Awesome Shoes" %}
|
||||||
These shoes are not awesome.
|
These shoes are not awesome.
|
||||||
{% endunless %}
|
{% endunless %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -46,7 +46,7 @@ This would be the equivalent of doing the following:
|
|||||||
|
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% if product.title != 'Awesome Shoes' %}
|
{% if product.title != "Awesome Shoes" %}
|
||||||
These shoes are not awesome.
|
These shoes are not awesome.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
@@ -59,10 +59,10 @@ Adds more conditions within an `if` or `unless` block.
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
<!-- If customer.name = 'anonymous' -->
|
<!-- If customer.name = "anonymous" -->
|
||||||
{% if customer.name == 'kevin' %}
|
{% if customer.name == "kevin" %}
|
||||||
Hey Kevin!
|
Hey Kevin!
|
||||||
{% elsif customer.name == 'anonymous' %}
|
{% elsif customer.name == "anonymous" %}
|
||||||
Hey Anonymous!
|
Hey Anonymous!
|
||||||
{% else %}
|
{% else %}
|
||||||
Hi Stranger!
|
Hi Stranger!
|
||||||
@@ -82,11 +82,11 @@ Creates a switch statement to compare a variable with different values. `case` i
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign handle = 'cake' %}
|
{% assign handle = "cake" %}
|
||||||
{% case handle %}
|
{% case handle %}
|
||||||
{% when 'cake' %}
|
{% when "cake" %}
|
||||||
This is a cake
|
This is a cake
|
||||||
{% when 'cookie' %}
|
{% when "cookie" %}
|
||||||
This is a cookie
|
This is a cookie
|
||||||
{% else %}
|
{% else %}
|
||||||
This is not a cake nor a cookie
|
This is not a cake nor a cookie
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: Iteration
|
title: Iteration
|
||||||
description: An overview of iteration or 'loop' tags in the Liquid template language.
|
description: An overview of iteration or "loop" tags in the Liquid template language.
|
||||||
---
|
---
|
||||||
|
|
||||||
Iteration tags run blocks of code repeatedly.
|
Iteration tags run blocks of code repeatedly.
|
||||||
@@ -179,10 +179,10 @@ Loops through a group of strings and outputs them in the order that they were pa
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% cycle 'one', 'two', 'three' %}
|
{% cycle "one", "two", "three" %}
|
||||||
{% cycle 'one', 'two', 'three' %}
|
{% cycle "one", "two", "three" %}
|
||||||
{% cycle 'one', 'two', 'three' %}
|
{% cycle "one", "two", "three" %}
|
||||||
{% cycle 'one', 'two', 'three' %}
|
{% cycle "one", "two", "three" %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ Using `capture`, you can create complex strings using other variables created wi
|
|||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign favorite_food = 'pizza' %}
|
{% assign favorite_food = "pizza" %}
|
||||||
{% assign age = 35 %}
|
{% assign age = 35 %}
|
||||||
|
|
||||||
{% capture about_me %}
|
{% capture about_me %}
|
||||||
|
|||||||
Reference in New Issue
Block a user