mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -07:00
Relocate {% raw %} tags inside code blocks
This commit is contained in:
@@ -95,9 +95,7 @@ To access all the items in an array, you can loop through each item in the array
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
```text
|
||||
{% raw %}
|
||||
Tobi Laura Tetsuro Adam
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Accessing specific items in arrays
|
||||
|
||||
+12
-12
@@ -8,17 +8,17 @@ In Liquid, you can include a hyphen in your tag syntax `{% raw %}{{-{% endraw %}
|
||||
Normally, even if it doesn't output text, any line of Liquid in your template will still output a blank line in your rendered HTML:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
``` liquid
|
||||
{% assign my_variable = "tomato" %}
|
||||
{{ my_variable }}
|
||||
```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Notice the blank line before "tomato" in the rendered template:
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
``` text
|
||||
```text
|
||||
{% assign my_variable = "tomato" %}
|
||||
{{ my_variable }}
|
||||
```
|
||||
@@ -26,34 +26,34 @@ Notice the blank line before "tomato" in the rendered template:
|
||||
By including hyphens in your `assign` tag, you can strip the generated whitespace from the rendered template:
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
``` liquid
|
||||
{%- assign my_variable = "tomato" -%}
|
||||
{{ my_variable }}
|
||||
```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output</p>
|
||||
``` text
|
||||
```text
|
||||
tomato
|
||||
```
|
||||
|
||||
If you don't want any of your tags to output whitespace, as a general rule you can add hyphens to both sides of all your tags (`{% raw %}{%-{% endraw %}` and `{% raw %}-%}{% endraw %}`):
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
``` liquid
|
||||
{% assign username = "John G. Chalmers-Smith" %}
|
||||
{% if username and username.size > 10 %}
|
||||
Wow, {{ username }}, you have a long name!
|
||||
{% else %}
|
||||
Hello there!
|
||||
{% endif %}
|
||||
```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output without whitespace control</p>
|
||||
``` text
|
||||
```text
|
||||
{% assign username = "John G. Chalmers-Smith" %}
|
||||
{% if username and username.size > 10 %}
|
||||
Wow, {{ username }}, you have a long name!
|
||||
@@ -63,18 +63,18 @@ If you don't want any of your tags to output whitespace, as a general rule you c
|
||||
```
|
||||
|
||||
<p class="code-label">Input</p>
|
||||
```liquid
|
||||
{% raw %}
|
||||
``` liquid
|
||||
{%- assign username = "John G. Chalmers-Smith" -%}
|
||||
{%- if username and username.size > 10 -%}
|
||||
Wow, {{ username }}, you have a long name!
|
||||
{%- else -%}
|
||||
Hello there!
|
||||
{%- endif -%}
|
||||
```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
<p class="code-label">Output with whitespace control</p>
|
||||
``` text
|
||||
```text
|
||||
Wow, John G. Chalmers-Smith, you have a long name!
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user