mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Drop blank lines from input examples
This commit is contained in:
@@ -12,7 +12,7 @@ Liquid uses a combination of [**objects**](#objects), [**tags**](#tags), and [**
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{{ page.title }}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -30,7 +30,7 @@ In this case, Liquid is rendering the content of the `title` property of the `pa
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if user %}
|
||||
Hello {{ user.name }}!
|
||||
{% endif %}
|
||||
@@ -57,7 +57,7 @@ You can read more about each type of tag in their respective sections.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -71,7 +71,7 @@ Multiple filters can be used on one output, and are applied from left to right.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{{ "adam!" | capitalize | prepend: "Hello " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
@@ -47,7 +47,7 @@ Liquid includes many logical and comparison operators. You can use operators to
|
||||
For example:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if product.title == "Awesome Shoes" %}
|
||||
These shoes are awesome!
|
||||
{% endif %}
|
||||
@@ -57,7 +57,7 @@ For example:
|
||||
You can do multiple comparisons in a tag using the `and` and `or` operators:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if product.type == "Shirt" or product.type == "Shoes" %}
|
||||
This is a shirt or a pair of shoes.
|
||||
{% endif %}
|
||||
@@ -69,7 +69,7 @@ You can do multiple comparisons in a tag using the `and` and `or` operators:
|
||||
`contains` checks for the presence of a substring inside a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if product.title contains "Pack" %}
|
||||
This product's title contains the word Pack.
|
||||
{% endif %}
|
||||
@@ -79,7 +79,7 @@ You can do multiple comparisons in a tag using the `and` and `or` operators:
|
||||
`contains` can also check for the presence of a string in an array of strings.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if product.tags contains "Hello" %}
|
||||
This product has been tagged with "Hello".
|
||||
{% endif %}
|
||||
@@ -93,7 +93,7 @@ You can do multiple comparisons in a tag using the `and` and `or` operators:
|
||||
In tags with more than one `and` or `or` operator, operators are checked in order *from right to left*. You cannot change the order of operations using parentheses — parentheses are invalid characters in Liquid and will prevent your tags from working.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if true or false and false %}
|
||||
This evaluates to true, since the `and` condition is checked first.
|
||||
{% endif %}
|
||||
@@ -101,7 +101,7 @@ In tags with more than one `and` or `or` operator, operators are checked in orde
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if true and false and false or true %}
|
||||
This evaluates to false, since the tags are checked like this:
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ All values in Liquid are truthy except `nil` and `false`.
|
||||
In the example below, the text "Tobi" is not a boolean, but it is truthy in a conditional:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign name = "Tobi" %}
|
||||
|
||||
{% if name %}
|
||||
@@ -25,7 +25,7 @@ In the example below, the text "Tobi" is not a boolean, but it is truthy in a co
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if page.category %}
|
||||
<h1>{{ page.category }}</h1>
|
||||
{% endif %}
|
||||
|
||||
+9
-9
@@ -19,7 +19,7 @@ You can initialize Liquid variables using [`assign`]({{ "/tags/variable/#assign"
|
||||
Strings are sequences of characters wrapped in single or double quotes:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign my_string = "Hello World!" %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -31,7 +31,7 @@ Liquid does not convert escape sequences into special characters.
|
||||
Numbers include floats and integers:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign my_int = 25 %}
|
||||
{% assign my_float = -39.756 %}
|
||||
{% endraw %}
|
||||
@@ -42,7 +42,7 @@ Numbers include floats and integers:
|
||||
Booleans are either `true` or `false`. No quotations are necessary when declaring a boolean:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign foo = true %}
|
||||
{% assign bar = false %}
|
||||
{% endraw %}
|
||||
@@ -57,7 +57,7 @@ Nil is [treated as false]({{ "/basics/truthy-and-falsy/#falsy" | prepend: site.b
|
||||
In the following example, if the user does not exist (that is, `user` returns `nil`), Liquid will not print the greeting:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% if user %}
|
||||
Hello {{ user.name }}!
|
||||
{% endif %}
|
||||
@@ -68,7 +68,7 @@ Tags or outputs that return `nil` will not print anything to the page.
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
The current user is {{ user.name }}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -88,7 +88,7 @@ To access all the items in an array, you can loop through each item in the array
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||
{% for user in site.users %}
|
||||
{{ user }}
|
||||
@@ -107,7 +107,7 @@ You can use square bracket `[` `]` notation to access a specific item in an arra
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||
{{ site.users[0] }}
|
||||
{{ site.users[1] }}
|
||||
@@ -133,7 +133,7 @@ You can, however, use the [`split`]({{ "/filters/split/" | prepend: site.baseurl
|
||||
An EmptyDrop object is returned if you try to access a deleted object. In the example below, `page_1`, `page_2` and `page_3` are all EmptyDrop objects:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign variable = "hello" %}
|
||||
{% assign page_1 = pages[variable] %}
|
||||
{% assign page_2 = pages["does-not-exist"] %}
|
||||
@@ -146,7 +146,7 @@ An EmptyDrop object is returned if you try to access a deleted object. In the ex
|
||||
You can check to see if an object exists or not before you access any of its attributes.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% unless pages == empty %}
|
||||
<h1>{{ pages.frontpage.title }}</h1>
|
||||
<div>{{ pages.frontpage.content }}</div>
|
||||
|
||||
@@ -9,7 +9,7 @@ Normally, even if it doesn't print text, any line of Liquid in your template wil
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign my_variable = "tomato" %}
|
||||
{{ my_variable }}
|
||||
{% endraw %}
|
||||
@@ -27,7 +27,7 @@ By including a hyphen in your `assign` closing delimiter, you can strip the whit
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign my_variable = "tomato" -%}
|
||||
{{ my_variable }}
|
||||
{% endraw %}
|
||||
@@ -43,7 +43,7 @@ If you don't want any of your tags to print whitespace, as a general rule you ca
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign username = "John G. Chalmers-Smith" %}
|
||||
{% if username and username.size > 10 %}
|
||||
Wow, {{ username }} , you have a long name!
|
||||
@@ -65,7 +65,7 @@ If you don't want any of your tags to print whitespace, as a general rule you ca
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
{%- raw -%}
|
||||
{% assign username = "John G. Chalmers-Smith" -%}
|
||||
{%- if username and username.size > 10 -%}
|
||||
Wow, {{ username -}} , you have a long name!
|
||||
|
||||
Reference in New Issue
Block a user