Relocate {% raw %} tags inside code blocks

This commit is contained in:
EricFromCanada
2019-09-09 22:59:33 -04:00
parent 9ff1b88985
commit ea6b176363
10 changed files with 64 additions and 66 deletions
-2
View File
@@ -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
View File
@@ -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!
```