diff --git a/_basics/introduction.md b/_basics/introduction.md index 8e080a4..f98b423 100644 --- a/_basics/introduction.md +++ b/_basics/introduction.md @@ -22,7 +22,7 @@ Liquid code can be categorized into [**objects**](#objects), [**tags**](#tags), {{ page.title }} ``` -In this case, Liquid is rendering the content of an object called `page.title`, and that object contains the text `Introduction`. +In this case, Liquid is rendering the content of the `title` property of the `page` object, which contains the text `{{ page.title }}`. ## Tags @@ -41,7 +41,7 @@ The markup used in tags does not produce any visible text. This means that you c
Output
```text -Hello Adam! + Hello Adam! ``` Tags can be categorized into three types: diff --git a/_basics/truthy-and-falsy.md b/_basics/truthy-and-falsy.md index b1fffb9..5703691 100644 --- a/_basics/truthy-and-falsy.md +++ b/_basics/truthy-and-falsy.md @@ -13,32 +13,32 @@ In programming, anything that returns `true` in a conditional is called **truthy All values in Liquid are truthy except `nil` and `false`. -In the example below, the string "Tobi" is not a boolean, but it is truthy in a conditional: +In the example below, the text "Tobi" is not a boolean, but it is truthy in a conditional: ```liquid {% raw %} -{% assign tobi = "Tobi" %} +{% assign name = "Tobi" %} -{% if tobi %} - This condition will always be true. +{% if name %} + This text will always appear since "name" is defined. {% endif %} {% endraw %} ``` -[Strings]({{ "/basics/types/#string" | prepend: site.baseurl }}), even when empty, are truthy. The example below will result in empty HTML tags if `settings.fp_heading` is empty: +[Strings]({{ "/basics/types/#string" | prepend: site.baseurl }}), even when empty, are truthy. The example below will create empty HTML tags if `page.category` exists but is empty:Input
```liquid {% raw %} -{% if settings.fp_heading %} -Output
```html - + ``` ## Falsy diff --git a/_basics/types.md b/_basics/types.md index d7c6c7b..cd058a0 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -95,7 +95,7 @@ To access all the items in an array, you can loop through each item in the arrayOutput
```text -Tobi Laura Tetsuro Adam + Tobi Laura Tetsuro Adam ``` ### Accessing specific items in arrays diff --git a/_basics/whitespace.md b/_basics/whitespace.md index 4dd20e5..77587bc 100644 --- a/_basics/whitespace.md +++ b/_basics/whitespace.md @@ -23,19 +23,20 @@ Notice the blank line before "tomato" in the rendered template: {{ my_variable }} ``` -By including hyphens in your `assign` tag, you can strip the generated whitespace from the rendered template: +By including a hyphen in your `assign` closing delimiter, you can strip the whitespace following it from the rendered template:Input
```liquid {% raw %} -{%- assign my_variable = "tomato" -%} +{% assign my_variable = "tomato" -%} {{ my_variable }} {% endraw %} ```Output
```text -tomato +{% assign my_variable = "tomato" -%} +{{ my_variable }} ``` If you don't want any of your tags to print whitespace, as a general rule you can add hyphens to both sides of all your tags (`{% raw %}{%-{% endraw %}` and `{% raw %}-%}{% endraw %}`): @@ -45,7 +46,7 @@ If you don't want any of your tags to print whitespace, as a general rule you ca {% raw %} {% assign username = "John G. Chalmers-Smith" %} {% if username and username.size > 10 %} - Wow, {{ username }}, you have a long name! + Wow, {{ username }} , you have a long name! {% else %} Hello there! {% endif %} @@ -56,7 +57,7 @@ If you don't want any of your tags to print whitespace, as a general rule you ca ```text {% assign username = "John G. Chalmers-Smith" %} {% if username and username.size > 10 %} - Wow, {{ username }}, you have a long name! + Wow, {{ username }} , you have a long name! {% else %} Hello there! {% endif %} @@ -65,16 +66,21 @@ If you don't want any of your tags to print whitespace, as a general rule you caInput
```liquid {% raw %} -{%- assign username = "John G. Chalmers-Smith" -%} +{% assign username = "John G. Chalmers-Smith" -%} {%- if username and username.size > 10 -%} - Wow, {{ username }}, you have a long name! + Wow, {{ username -}} , you have a long name! {%- else -%} Hello there! -{%- endif -%} +{%- endif %} {% endraw %} ```Output with whitespace control
```text -Wow, John G. Chalmers-Smith, you have a long name! +{% assign username = "John G. Chalmers-Smith" -%} +{%- if username and username.size > 10 -%} + Wow, {{ username -}} , you have a long name! +{%- else -%} + Hello there! +{%- endif %} ``` diff --git a/_filters/abs.md b/_filters/abs.md index ee28e19..5fc0646 100644 --- a/_filters/abs.md +++ b/_filters/abs.md @@ -10,23 +10,13 @@ Returns the absolute value of a number. ```liquid {% raw %} {{ -17 | abs }} -{% endraw %} -``` - -Output
-```text -{{ -17 | abs }} -``` - -Input
-```liquid -{% raw %} {{ 4 | abs }} {% endraw %} ```Output
```text +{{ -17 | abs }} {{ 4 | abs }} ``` diff --git a/_filters/at_least.md b/_filters/at_least.md index 3bb2b14..3e74b76 100644 --- a/_filters/at_least.md +++ b/_filters/at_least.md @@ -9,22 +9,12 @@ Limits a number to a minimum value. ```liquid {% raw %} {{ 4 | at_least: 5 }} -{% endraw %} -``` - -Output
-```text -5 -``` - -Input
-```liquid -{% raw %} {{ 4 | at_least: 3 }} {% endraw %} ```Output
```text +5 4 ``` diff --git a/_filters/at_most.md b/_filters/at_most.md index 9599ee2..9c8ed37 100644 --- a/_filters/at_most.md +++ b/_filters/at_most.md @@ -9,22 +9,12 @@ Limits a number to a maximum value. ```liquid {% raw %} {{ 4 | at_most: 5 }} -{% endraw %} -``` - -Output
-```text -4 -``` - -Input
-```liquid -{% raw %} {{ 4 | at_most: 3 }} {% endraw %} ```Output
```text +4 3 ``` diff --git a/_filters/ceil.md b/_filters/ceil.md index debc688..825519f 100644 --- a/_filters/ceil.md +++ b/_filters/ceil.md @@ -9,35 +9,15 @@ Rounds the input up to the nearest whole number. Liquid tries to convert the inp ```liquid {% raw %} {{ 1.2 | ceil }} -{% endraw %} -``` - -Output
-```text -{{ 1.2 | ceil }} -``` - -Input
-```liquid -{% raw %} {{ 2.0 | ceil }} -{% endraw %} -``` - -Output
-```text -{{ 2.0 | ceil }} -``` - -Input
-```liquid -{% raw %} {{ 183.357 | ceil }} {% endraw %} ```Output
```text +{{ 1.2 | ceil }} +{{ 2.0 | ceil }} {{ 183.357 | ceil }} ``` diff --git a/_filters/default.md b/_filters/default.md index 9437cd5..5366cb4 100644 --- a/_filters/default.md +++ b/_filters/default.md @@ -16,7 +16,7 @@ In this example, `product_price` is not defined, so the default value is used.Output
```text -2.99 +{{ product_price | default: 2.99 }} ``` In this example, `product_price` is defined, so the default value is not used. @@ -31,7 +31,8 @@ In this example, `product_price` is defined, so the default value is not used.Output
```text -4.99 +{% assign product_price = 4.99 %} +{{ product_price | default: 2.99 }} ``` In this example, `product_price` is empty, so the default value is used. @@ -46,5 +47,6 @@ In this example, `product_price` is empty, so the default value is used.Output
```text -2.99 +{% assign product_price = "" %} +{{ product_price | default: 2.99 }} ``` diff --git a/_filters/divided_by.md b/_filters/divided_by.md index f87d9b1..500ca56 100644 --- a/_filters/divided_by.md +++ b/_filters/divided_by.md @@ -11,23 +11,13 @@ The result is rounded down to the nearest integer (that is, the [floor]({{ "/fil ```liquid {% raw %} {{ 16 | divided_by: 4 }} -{% endraw %} -``` - -Output
-```text -{{ 16 | divided_by: 4 }} -``` - -Input
-```liquid -{% raw %} {{ 5 | divided_by: 3 }} {% endraw %} ```Output
```text +{{ 16 | divided_by: 4 }} {{ 5 | divided_by: 3 }} ``` diff --git a/_filters/floor.md b/_filters/floor.md index 1b12697..c70a223 100644 --- a/_filters/floor.md +++ b/_filters/floor.md @@ -9,35 +9,15 @@ Rounds the input down to the nearest whole number. Liquid tries to convert the i ```liquid {% raw %} {{ 1.2 | floor }} -{% endraw %} -``` - -Output
-```text -{{ 1.2 | floor }} -``` - -Input
-```liquid -{% raw %} {{ 2.0 | floor }} -{% endraw %} -``` - -Output
-```text -{{ 2.0 | floor }} -``` - -Input
-```liquid -{% raw %} {{ 183.357 | floor }} {% endraw %} ```Output
```text +{{ 1.2 | floor }} +{{ 2.0 | floor }} {{ 183.357 | floor }} ``` diff --git a/_filters/lstrip.md b/_filters/lstrip.md index c9b9294..b2fd5a5 100644 --- a/_filters/lstrip.md +++ b/_filters/lstrip.md @@ -8,11 +8,11 @@ Removes all whitespace (tabs, spaces, and newlines) from the left side of a striInput
```liquid {% raw %} -{{ " So much room for activities! " | lstrip }} +{{ " So much room for activities " | lstrip }}! {% endraw %} ```Output
```text -{{ " So much room for activities! " | lstrip }} +{{ " So much room for activities " | lstrip }}! ``` diff --git a/_filters/minus.md b/_filters/minus.md index d1f65b5..60963ec 100644 --- a/_filters/minus.md +++ b/_filters/minus.md @@ -9,34 +9,14 @@ Subtracts a number from another number. ```liquid {% raw %} {{ 4 | minus: 2 }} +{{ 16 | minus: 4 }} +{{ 183.357 | minus: 12 }} {% endraw %} ```Output
```text {{ 4 | minus: 2 }} -``` - -Input
-```liquid -{% raw %} {{ 16 | minus: 4 }} -{% endraw %} -``` - -Output
-```text -{{ 16 | minus: 4 }} -``` - -Input
-```liquid -{% raw %} -{{ 183.357 | minus: 12 }} -{% endraw %} -``` - -Output
-```text {{ 183.357 | minus: 12 }} ``` diff --git a/_filters/modulo.md b/_filters/modulo.md index 17e79bc..f71c3dc 100644 --- a/_filters/modulo.md +++ b/_filters/modulo.md @@ -9,34 +9,14 @@ Returns the remainder of a division operation. ```liquid {% raw %} {{ 3 | modulo: 2 }} +{{ 24 | modulo: 7 }} +{{ 183.357 | modulo: 12 }} {% endraw %} ```Output
```text {{ 3 | modulo: 2 }} -``` - -Input
-```liquid -{% raw %} {{ 24 | modulo: 7 }} -{% endraw %} -``` - -Output
-```text -{{ 24 | modulo: 7 }} -``` - -Input
-```liquid -{% raw %} -{{ 183.357 | modulo: 12 }} -{% endraw %} -``` - -Output
-```text {{ 183.357 | modulo: 12 }} ``` diff --git a/_filters/plus.md b/_filters/plus.md index 1100220..a677940 100644 --- a/_filters/plus.md +++ b/_filters/plus.md @@ -9,34 +9,14 @@ Adds a number to another number. ```liquid {% raw %} {{ 4 | plus: 2 }} +{{ 16 | plus: 4 }} +{{ 183.357 | plus: 12 }} {% endraw %} ```Output
```text {{ 4 | plus: 2 }} -``` - -Input
-```liquid -{% raw %} {{ 16 | plus: 4 }} -{% endraw %} -``` - -Output
-```text -{{ 16 | plus: 4 }} -``` - -Input
-```liquid -{% raw %} -{{ 183.357 | plus: 12 }} -{% endraw %} -``` - -Output
-```text {{ 183.357 | plus: 12 }} ``` diff --git a/_filters/round.md b/_filters/round.md index d95c4fa..7050fbd 100644 --- a/_filters/round.md +++ b/_filters/round.md @@ -9,34 +9,14 @@ Rounds a number to the nearest integer or, if a number is passed as an argument, ```liquid {% raw %} {{ 1.2 | round }} +{{ 2.7 | round }} +{{ 183.357 | round: 2 }} {% endraw %} ```Output
```text {{ 1.2 | round }} -``` - -Input
-```liquid -{% raw %} {{ 2.7 | round }} -{% endraw %} -``` - -Output
-```text -{{ 2.7 | round }} -``` - -Input
-```liquid -{% raw %} -{{ 183.357 | round: 2 }} -{% endraw %} -``` - -Output
-```text {{ 183.357 | round: 2 }} ``` diff --git a/_filters/rstrip.md b/_filters/rstrip.md index 25e64f2..eb86574 100644 --- a/_filters/rstrip.md +++ b/_filters/rstrip.md @@ -8,11 +8,11 @@ Removes all whitespace (tabs, spaces, and newlines) from the right side of a strInput
```liquid {% raw %} -{{ " So much room for activities! " | rstrip }} +{{ " So much room for activities " | rstrip }}! {% endraw %} ```Output
```text -{{ " So much room for activities! " | rstrip }} +{{ " So much room for activities " | rstrip }}! ``` diff --git a/_filters/strip.md b/_filters/strip.md index 3efdad2..59d2402 100644 --- a/_filters/strip.md +++ b/_filters/strip.md @@ -8,11 +8,11 @@ Removes all whitespace (tabs, spaces, and newlines) from both the left and rightInput
```liquid {% raw %} -{{ " So much room for activities! " | strip }} +{{ " So much room for activities " | strip }}! {% endraw %} ```Output
```text -{{ " So much room for activities! " | strip }} +{{ " So much room for activities " | strip }}! ``` diff --git a/_filters/times.md b/_filters/times.md index 634c7e4..8863996 100644 --- a/_filters/times.md +++ b/_filters/times.md @@ -9,34 +9,14 @@ Multiplies a number by another number. ```liquid {% raw %} {{ 3 | times: 2 }} +{{ 24 | times: 7 }} +{{ 183.357 | times: 12 }} {% endraw %} ```Output
```text {{ 3 | times: 2 }} -``` - -Input
-```liquid -{% raw %} {{ 24 | times: 7 }} -{% endraw %} -``` - -Output
-```text -{{ 24 | times: 7 }} -``` - -Input
-```liquid -{% raw %} -{{ 183.357 | times: 12 }} -{% endraw %} -``` - -Output
-```text {{ 183.357 | times: 12 }} ``` diff --git a/_tags/iteration.md b/_tags/iteration.md index 72ee37c..2d2ae69 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -188,10 +188,10 @@ Loops through a group of strings and prints them in the order that they were pasOutput
```text -one -two -three -one +{% cycle "one", "two", "three" %} +{% cycle "one", "two", "three" %} +{% cycle "one", "two", "three" %} +{% cycle "one", "two", "three" %} ``` Uses for `cycle` include: @@ -215,10 +215,10 @@ Uses for `cycle` include:Output
```text -one -one -two -two +{% cycle "first": "one", "two", "three" %} +{% cycle "second": "one", "two", "three" %} +{% cycle "second": "one", "two", "three" %} +{% cycle "first": "one", "two", "three" %} ``` ## tablerow diff --git a/_tags/raw.md b/_tags/raw.md index 49ba629..610b329 100644 --- a/_tags/raw.md +++ b/_tags/raw.md @@ -7,16 +7,15 @@ Raw temporarily disables tag processing. This is useful for generating content (eg, Mustache, Handlebars) which uses conflicting syntax.Input
-
-{% raw %}
-{% raw %}
- In Handlebars, {{ this }} will be HTML-escaped, but
- {{{ that }}} will not.
-{% endraw %}
-{% endraw %}
-
+```liquid
+{{ "%7B%25+raw+%25%7D" | url_decode }}{% raw %}
+In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not.
+{% endraw %}{{ "%7B%25+endraw+%25%7D" | url_decode }}
+```
Output
```text -{% raw %}In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not.{% endraw %} +{% raw %} +In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not. +{% endraw %} ``` diff --git a/_tags/variable.md b/_tags/variable.md index 062f38f..76124bb 100644 --- a/_tags/variable.md +++ b/_tags/variable.md @@ -36,7 +36,8 @@ Wrap a variable value in quotations `"` to save it as a string.Output
```text -bar +{% assign foo = "bar" %} +{{ foo }} ``` ## capture @@ -92,9 +93,9 @@ Creates and outputs a new number variable with initial value `0`. On subsequentOutput
```text -0 -1 -2 +{% increment my_counter %} +{% increment my_counter %} +{% increment my_counter %} ``` Variables created through the `increment` tag are independent from variables created through `assign` or `capture`. @@ -114,10 +115,11 @@ In the example below, a variable named "var" is created through `assign`. The `iOutput
```text -0 -1 -2 -10 +{% assign var = 10 %} +{% increment var %} +{% increment var %} +{% increment var %} +{{ var }} ``` ## decrement @@ -135,9 +137,9 @@ Creates and outputs a new number variable with initial value `-1`. On subsequentOutput
```text --1 --2 --3 +{% decrement variable %} +{% decrement variable %} +{% decrement variable %} ``` Like [increment](#increment), variables declared inside `decrement` are independent from variables created through `assign` or `capture`.