From 537f53ef7ccca2b31d61cdd547fc1d3fd2a58b1d Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 25 Jan 2021 16:34:29 -0500 Subject: [PATCH 01/18] Remove ignored Gemfile.lock --- Gemfile.lock | 265 --------------------------------------------------- 1 file changed, 265 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 76e319405..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,265 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (6.0.3.5) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.11.1) - colorator (1.1.0) - commonmarker (0.17.13) - ruby-enum (~> 0.5) - concurrent-ruby (1.1.8) - dnsruby (1.61.5) - simpleidn (~> 0.1) - em-websocket (0.5.2) - eventmachine (>= 0.12.9) - http_parser.rb (~> 0.6.0) - ethon (0.12.0) - ffi (>= 1.3.0) - eventmachine (1.2.7) - execjs (2.7.0) - faraday (1.3.0) - faraday-net_http (~> 1.0) - multipart-post (>= 1.2, < 3) - ruby2_keywords - faraday-net_http (1.0.1) - ffi (1.15.0) - forwardable-extended (2.6.0) - gemoji (3.0.1) - github-pages (212) - github-pages-health-check (= 1.17.0) - jekyll (= 3.9.0) - jekyll-avatar (= 0.7.0) - jekyll-coffeescript (= 1.1.1) - jekyll-commonmark-ghpages (= 0.1.6) - jekyll-default-layout (= 0.1.4) - jekyll-feed (= 0.15.1) - jekyll-gist (= 1.5.0) - jekyll-github-metadata (= 2.13.0) - jekyll-mentions (= 1.6.0) - jekyll-optional-front-matter (= 0.3.2) - jekyll-paginate (= 1.1.0) - jekyll-readme-index (= 0.3.0) - jekyll-redirect-from (= 0.16.0) - jekyll-relative-links (= 0.6.1) - jekyll-remote-theme (= 0.4.2) - jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.7.1) - jekyll-sitemap (= 1.4.0) - jekyll-swiss (= 1.0.0) - jekyll-theme-architect (= 0.1.1) - jekyll-theme-cayman (= 0.1.1) - jekyll-theme-dinky (= 0.1.1) - jekyll-theme-hacker (= 0.1.2) - jekyll-theme-leap-day (= 0.1.1) - jekyll-theme-merlot (= 0.1.1) - jekyll-theme-midnight (= 0.1.1) - jekyll-theme-minimal (= 0.1.1) - jekyll-theme-modernist (= 0.1.1) - jekyll-theme-primer (= 0.5.4) - jekyll-theme-slate (= 0.1.1) - jekyll-theme-tactile (= 0.1.1) - jekyll-theme-time-machine (= 0.1.1) - jekyll-titles-from-headings (= 0.5.3) - jemoji (= 0.12.0) - kramdown (= 2.3.0) - kramdown-parser-gfm (= 1.1.0) - liquid (= 4.0.3) - mercenary (~> 0.3) - minima (= 2.5.1) - nokogiri (>= 1.10.4, < 2.0) - rouge (= 3.26.0) - terminal-table (~> 1.4) - github-pages-health-check (1.17.0) - addressable (~> 2.3) - dnsruby (~> 1.60) - octokit (~> 4.0) - public_suffix (>= 2.0.2, < 5.0) - typhoeus (~> 1.3) - html-pipeline (2.14.0) - activesupport (>= 2) - nokogiri (>= 1.4) - http_parser.rb (0.6.0) - i18n (0.9.5) - concurrent-ruby (~> 1.0) - jekyll (3.9.0) - addressable (~> 2.4) - colorator (~> 1.0) - em-websocket (~> 0.5) - i18n (~> 0.7) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 2.0) - kramdown (>= 1.17, < 3) - liquid (~> 4.0) - mercenary (~> 0.3.3) - pathutil (~> 0.9) - rouge (>= 1.7, < 4) - safe_yaml (~> 1.0) - jekyll-avatar (0.7.0) - jekyll (>= 3.0, < 5.0) - jekyll-coffeescript (1.1.1) - coffee-script (~> 2.2) - coffee-script-source (~> 1.11.1) - jekyll-commonmark (1.3.1) - commonmarker (~> 0.14) - jekyll (>= 3.7, < 5.0) - jekyll-commonmark-ghpages (0.1.6) - commonmarker (~> 0.17.6) - jekyll-commonmark (~> 1.2) - rouge (>= 2.0, < 4.0) - jekyll-default-layout (0.1.4) - jekyll (~> 3.0) - jekyll-feed (0.15.1) - jekyll (>= 3.7, < 5.0) - jekyll-gist (1.5.0) - octokit (~> 4.2) - jekyll-github-metadata (2.13.0) - jekyll (>= 3.4, < 5.0) - octokit (~> 4.0, != 4.4.0) - jekyll-mentions (1.6.0) - html-pipeline (~> 2.3) - jekyll (>= 3.7, < 5.0) - jekyll-optional-front-matter (0.3.2) - jekyll (>= 3.0, < 5.0) - jekyll-paginate (1.1.0) - jekyll-readme-index (0.3.0) - jekyll (>= 3.0, < 5.0) - jekyll-redirect-from (0.16.0) - jekyll (>= 3.3, < 5.0) - jekyll-relative-links (0.6.1) - jekyll (>= 3.3, < 5.0) - jekyll-remote-theme (0.4.2) - addressable (~> 2.0) - jekyll (>= 3.5, < 5.0) - jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0) - rubyzip (>= 1.3.0, < 3.0) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-seo-tag (2.7.1) - jekyll (>= 3.8, < 5.0) - jekyll-sitemap (1.4.0) - jekyll (>= 3.7, < 5.0) - jekyll-swiss (1.0.0) - jekyll-theme-architect (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-cayman (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-dinky (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-hacker (0.1.2) - jekyll (> 3.5, < 5.0) - jekyll-seo-tag (~> 2.0) - jekyll-theme-leap-day (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-merlot (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-midnight (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-minimal (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-modernist (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-primer (0.5.4) - jekyll (> 3.5, < 5.0) - jekyll-github-metadata (~> 2.9) - jekyll-seo-tag (~> 2.0) - jekyll-theme-slate (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-tactile (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-theme-time-machine (0.1.1) - jekyll (~> 3.5) - jekyll-seo-tag (~> 2.0) - jekyll-titles-from-headings (0.5.3) - jekyll (>= 3.3, < 5.0) - jekyll-watch (2.2.1) - listen (~> 3.0) - jemoji (0.12.0) - gemoji (~> 3.0) - html-pipeline (~> 2.2) - jekyll (>= 3.0, < 5.0) - kramdown (2.3.0) - rexml - kramdown-parser-gfm (1.1.0) - kramdown (~> 2.0) - liquid (4.0.3) - listen (3.4.1) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - mercenary (0.3.6) - mini_portile2 (2.5.0) - minima (2.5.1) - jekyll (>= 3.5, < 5.0) - jekyll-feed (~> 0.9) - jekyll-seo-tag (~> 2.1) - minitest (5.14.4) - multipart-post (2.1.1) - nokogiri (1.11.1) - mini_portile2 (~> 2.5.0) - racc (~> 1.4) - octokit (4.20.0) - faraday (>= 0.9) - sawyer (~> 0.8.0, >= 0.5.3) - pathutil (0.16.2) - forwardable-extended (~> 2.6) - public_suffix (4.0.6) - racc (1.5.2) - rb-fsevent (0.10.4) - rb-inotify (0.10.1) - ffi (~> 1.0) - rexml (3.2.4) - rouge (3.26.0) - ruby-enum (0.9.0) - i18n - ruby2_keywords (0.0.4) - rubyzip (2.3.0) - safe_yaml (1.0.5) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.2) - addressable (>= 2.3.5) - faraday (> 0.8, < 2.0) - simpleidn (0.2.1) - unf (~> 0.1.4) - terminal-table (1.8.0) - unicode-display_width (~> 1.1, >= 1.1.1) - thread_safe (0.3.6) - typhoeus (1.4.0) - ethon (>= 0.9.0) - tzinfo (1.2.9) - thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.7) - unicode-display_width (1.7.0) - zeitwerk (2.4.2) - -PLATFORMS - ruby - -DEPENDENCIES - github-pages (>= 180) - -BUNDLED WITH - 2.1.4 From e47ea38940cdc20ff3e17e5b65ea76d893dffd06 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 13:53:20 -0500 Subject: [PATCH 02/18] Condense and improve examples --- _basics/introduction.md | 4 ++-- _basics/truthy-and-falsy.md | 16 ++++++++-------- _basics/types.md | 2 +- _basics/whitespace.md | 24 +++++++++++++++--------- _filters/abs.md | 12 +----------- _filters/at_least.md | 12 +----------- _filters/at_most.md | 12 +----------- _filters/ceil.md | 24 ++---------------------- _filters/default.md | 8 +++++--- _filters/divided_by.md | 12 +----------- _filters/floor.md | 24 ++---------------------- _filters/lstrip.md | 4 ++-- _filters/minus.md | 24 ++---------------------- _filters/modulo.md | 24 ++---------------------- _filters/plus.md | 24 ++---------------------- _filters/round.md | 24 ++---------------------- _filters/rstrip.md | 4 ++-- _filters/strip.md | 4 ++-- _filters/times.md | 24 ++---------------------- _tags/iteration.md | 16 ++++++++-------- _tags/raw.md | 17 ++++++++--------- _tags/variable.md | 24 +++++++++++++----------- 22 files changed, 84 insertions(+), 255 deletions(-) diff --git a/_basics/introduction.md b/_basics/introduction.md index 8e080a4d2..f98b423cb 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 b1fffb979..5703691d2 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 %} -

{{ settings.fp_heading }}

+{% if page.category %} +

{{ page.category }}

{% endif %} {% endraw %} ```

Output

```html -

+

``` ## Falsy diff --git a/_basics/types.md b/_basics/types.md index d7c6c7bf2..cd058a07b 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 array

Output

```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 4dd20e58c..77587bc0e 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 ca

Input

```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 ee28e19bd..5fc06463d 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 3bb2b141f..3e74b76c7 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 9599ee218..9c8ed37a8 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 debc68881..825519fee 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 9437cd507..5366cb408 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 f87d9b19b..500ca5629 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 1b1269784..c70a22341 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 c9b929402..b2fd5a58f 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 stri

Input

```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 d1f65b5a2..60963ec4e 100644 --- a/_filters/minus.md +++ b/_filters/minus.md @@ -9,34 +9,14 @@ Subtracts a number from another number. ```liquid {% raw %} {{ 4 | minus: 2 }} -{% 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 +{{ 4 | minus: 2 }} +{{ 16 | minus: 4 }} {{ 183.357 | minus: 12 }} ``` diff --git a/_filters/modulo.md b/_filters/modulo.md index 17e79bc35..f71c3dc0f 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 }} -{% 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 +{{ 3 | modulo: 2 }} +{{ 24 | modulo: 7 }} {{ 183.357 | modulo: 12 }} ``` diff --git a/_filters/plus.md b/_filters/plus.md index 110022054..a67794075 100644 --- a/_filters/plus.md +++ b/_filters/plus.md @@ -9,34 +9,14 @@ Adds a number to another number. ```liquid {% raw %} {{ 4 | plus: 2 }} -{% 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 +{{ 4 | plus: 2 }} +{{ 16 | plus: 4 }} {{ 183.357 | plus: 12 }} ``` diff --git a/_filters/round.md b/_filters/round.md index d95c4fa77..7050fbd1c 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 }} -{% 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 +{{ 1.2 | round }} +{{ 2.7 | round }} {{ 183.357 | round: 2 }} ``` diff --git a/_filters/rstrip.md b/_filters/rstrip.md index 25e64f266..eb8657448 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 str

Input

```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 3efdad252..59d240254 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 right

Input

```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 634c7e49d..8863996fa 100644 --- a/_filters/times.md +++ b/_filters/times.md @@ -9,34 +9,14 @@ Multiplies a number by another number. ```liquid {% raw %} {{ 3 | times: 2 }} -{% 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 +{{ 3 | times: 2 }} +{{ 24 | times: 7 }} {{ 183.357 | times: 12 }} ``` diff --git a/_tags/iteration.md b/_tags/iteration.md index 72ee37c65..2d2ae69f6 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 pas

Output

```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 49ba6292c..610b3296f 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 062f38fd7..76124bb51 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 subsequent

Output

```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 `i

Output

```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 subsequent

Output

```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`. From 32a327ed30f2c7808bf9b7b8343be4863af7ae42 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 14:04:31 -0500 Subject: [PATCH 03/18] Update URLs --- _basics/variations.md | 4 ++-- _tags/iteration.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_basics/variations.md b/_basics/variations.md index 5aa21599a..ad3113069 100644 --- a/_basics/variations.md +++ b/_basics/variations.md @@ -11,7 +11,7 @@ This site documents the latest version of **Liquid** including betas and release Shopify always uses the latest version of Liquid as a base, but Shopify adds a significant number of objects, tags, and filters to Liquid for use in merchants' stores. These include objects representing store, product, and customer information, and filters for displaying store data and manipulating storefront assets like product images. -Shopify's version of Liquid is documented in the [Shopify Help Center](https://help.shopify.com/themes/liquid). If you want to try out Shopify's version of Liquid, you can create a development store through the [Shopify Partner Dashboard](https://help.shopify.com/en/partners/dashboard/development-stores). +Shopify's version of Liquid is documented in the [Shopify developer documentation](https://shopify.dev/docs/themes/liquid/reference). If you want to try out Shopify's version of Liquid, you can create a development store through the [Shopify Partner Dashboard](https://help.shopify.com/en/partners/dashboard/managing-stores/development-stores). ## Jekyll @@ -19,6 +19,6 @@ Shopify's version of Liquid is documented in the [Shopify Help Center](https://h Jekyll also powers [GitHub Pages](https://pages.github.com/), a web hosting service that lets you push a Jekyll installation to a GitHub repository and have the resulting website published. This website is built using GitHub Pages. -Jekyll might not be using the latest version of Liquid. This means that the tags and filters listed on this site may not work in Jekyll. Often the Jekyll project will wait for a stable release of Liquid rather than using a beta or release candidate version. To see what version of Liquid Jekyll is using, check the **runtime dependencies** section of [Jekyll's gem page](https://rubygems.org/gems/jekyll). +Jekyll might not be using the latest version of Liquid. This means that the tags and filters listed on this site may not work in Jekyll. Often the Jekyll project will wait for a stable release of Liquid rather than using a beta or release candidate version. To see which version of Liquid is being used by Jekyll or GitHub Pages, check the **runtime dependencies** section of the gem page for [Jekyll](https://rubygems.org/gems/jekyll) or [GitHub Pages](https://rubygems.org/gems/github-pages). Jekyll's version of Liquid is documented in the [Liquid section of Jekyll's documentation](https://jekyllrb.com/docs/liquid/). If you want to try out Jekyll's version of Liquid, you can clone the Jekyll project or install Jekyll as a gem and test Liquid on a static site. diff --git a/_tags/iteration.md b/_tags/iteration.md index 2d2ae69f6..1db7709fa 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -7,7 +7,7 @@ Iteration tags run blocks of code repeatedly. ## for -Repeatedly executes a block of code. For a full list of attributes available within a `for` loop, see [forloop (object)](https://help.shopify.com/themes/liquid/objects/for-loops). +Repeatedly executes a block of code. For a full list of attributes available within a `for` loop, see [forloop (object)](https://shopify.dev/docs/themes/liquid/reference/objects/for-loops).

Input

```liquid @@ -223,7 +223,7 @@ Uses for `cycle` include: ## tablerow -Generates an HTML table. Must be wrapped in opening `` and closing `
` HTML tags. +Generates an HTML table. Must be wrapped in opening `` and closing `
` HTML tags. For a full list of attributes available within a `tablerow` loop, see [tablerow (object)](https://shopify.dev/docs/themes/liquid/reference/objects/tablerow).

Input

```liquid From 9542f1d9614f85ff46f7de4c791d28eb467fb8b3 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 14:14:20 -0500 Subject: [PATCH 04/18] Show version badge on recently-added tags --- _filters/at_least.md | 1 + _filters/at_most.md | 1 + _filters/compact.md | 1 + _filters/concat.md | 1 + _filters/sort_natural.md | 1 + _filters/url_decode.md | 1 + _filters/where.md | 1 + _includes/version-badge.html | 1 + _layouts/default.html | 7 ++++++- _sass/modules/_content-area.scss | 15 +++++++++++++++ 10 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 _includes/version-badge.html diff --git a/_filters/at_least.md b/_filters/at_least.md index 3e74b76c7..ab61b36b1 100644 --- a/_filters/at_least.md +++ b/_filters/at_least.md @@ -1,6 +1,7 @@ --- title: at_least description: Liquid filter that limits a number to a minimum value. +version-badge: 4.0.1 --- Limits a number to a minimum value. diff --git a/_filters/at_most.md b/_filters/at_most.md index 9c8ed37a8..f8f208c82 100644 --- a/_filters/at_most.md +++ b/_filters/at_most.md @@ -1,6 +1,7 @@ --- title: at_most description: Liquid filter that limits a number to a maximum value. +version-badge: 4.0.1 --- Limits a number to a maximum value. diff --git a/_filters/compact.md b/_filters/compact.md index 2847104e6..d9c307508 100644 --- a/_filters/compact.md +++ b/_filters/compact.md @@ -1,6 +1,7 @@ --- title: compact description: Liquid filter that removes nil values from an array. +version-badge: 4.0.0 --- Removes any `nil` values from an array. diff --git a/_filters/concat.md b/_filters/concat.md index a41b60480..18a9b4479 100644 --- a/_filters/concat.md +++ b/_filters/concat.md @@ -1,6 +1,7 @@ --- title: concat description: Liquid filter that concatenates arrays. +version-badge: 4.0.0 --- Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays. diff --git a/_filters/sort_natural.md b/_filters/sort_natural.md index 316cb76ad..dadeac733 100644 --- a/_filters/sort_natural.md +++ b/_filters/sort_natural.md @@ -1,6 +1,7 @@ --- title: sort_natural description: Liquid filter that sorts an array in case-insensitive order. +version-badge: 4.0.0 --- Sorts items in an array in case-insensitive order. diff --git a/_filters/url_decode.md b/_filters/url_decode.md index bf240c194..e2a7f05f5 100644 --- a/_filters/url_decode.md +++ b/_filters/url_decode.md @@ -1,6 +1,7 @@ --- title: url_decode description: Liquid filter that decodes percent-encoded characters in a string. +version-badge: 4.0.0 --- Decodes a string that has been encoded as a URL or by [url_encode]({{ "/filters/url_encode/" | prepend: site.baseurl }}). diff --git a/_filters/where.md b/_filters/where.md index 70f797f03..d28967edb 100644 --- a/_filters/where.md +++ b/_filters/where.md @@ -1,6 +1,7 @@ --- title: where description: Liquid filter that selects from arrays. +version-badge: 4.0.2 --- Creates an array including only the objects with a given property value, or any [truthy]({{ "/basics/truthy-and-falsy/#truthy" | prepend: site.baseurl }}) value by default. diff --git a/_includes/version-badge.html b/_includes/version-badge.html new file mode 100644 index 000000000..880c51699 --- /dev/null +++ b/_includes/version-badge.html @@ -0,0 +1 @@ + diff --git a/_layouts/default.html b/_layouts/default.html index e942e797e..b0fe697bd 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -55,7 +55,12 @@ Menu - {% if page.title %}

{{ page.title }}

{% endif %} + {% if page.title -%} +

{{ page.title }} + {%- if page.version-badge -%} + {%- include version-badge.html version=page.version-badge -%} + {%- endif -%}

+ {%- endif %} {{ content }} diff --git a/_sass/modules/_content-area.scss b/_sass/modules/_content-area.scss index dbee405be..ecbcac139 100644 --- a/_sass/modules/_content-area.scss +++ b/_sass/modules/_content-area.scss @@ -20,3 +20,18 @@ border-top: none; border-radius: 0 0 3px 3px; } + +.version-badge { + padding: 4px; + margin-left: 10px; + font-size: 12px; + font-weight: 300; + background: lighten($color-blue-1, 1); + border: 1px solid $color-blue-2; + border-radius: 3px; + vertical-align: middle; +} + +.version-badge:before { + content: attr(data-version); +} From c4dce51f62b35abc584f59e3ac266a9855fa1a8c Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 16:20:37 -0500 Subject: [PATCH 05/18] Filters can be used during variable assignment --- _basics/introduction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_basics/introduction.md b/_basics/introduction.md index f98b423cb..639bb64c6 100644 --- a/_basics/introduction.md +++ b/_basics/introduction.md @@ -54,7 +54,7 @@ You can read more about each type of tag in their respective sections. ## Filters -**Filters** change the output of a Liquid object. They are used within an output and are separated by a `|`. +**Filters** change the output of a Liquid object or variable. They are used within double curly braces `{% raw %}{{ }}{% endraw %}` and [variable assignment]({{ "/tags/variable/" | prepend: site.baseurl }}), and are separated by a pipe character `|`.

Input

```liquid From d4222ff2b6034e7cab189b85e428906dac9aebf8 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 16:23:05 -0500 Subject: [PATCH 06/18] Numbers and array indices can be negative --- _basics/types.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_basics/types.md b/_basics/types.md index cd058a07b..dd57044b9 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -30,7 +30,7 @@ Numbers include floats and integers: ```liquid {% raw %} {% assign my_int = 25 %} -{% assign my_float = 39.756 %} +{% assign my_float = -39.756 %} {% endraw %} ``` @@ -100,7 +100,7 @@ To access all the items in an array, you can loop through each item in the array ### Accessing specific items in arrays -You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero. +You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero. A negative index will count from the end of the array.

Input

```liquid @@ -108,7 +108,7 @@ You can use square bracket `[` `]` notation to access a specific item in an arra {{ site.users[0] }} {{ site.users[1] }} -{{ site.users[3] }} +{{ site.users[-1] }} {% endraw %} ``` From 9e0dc135ca9dea775deb2ef060bd397671b033c8 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 16:34:14 -0500 Subject: [PATCH 07/18] {% when %} can have multiple cases --- _tags/control-flow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tags/control-flow.md b/_tags/control-flow.md index 83f30fc3f..3a99343ed 100644 --- a/_tags/control-flow.md +++ b/_tags/control-flow.md @@ -86,7 +86,7 @@ Creates a switch statement to compare a variable with different values. `case` i {% case handle %} {% when "cake" %} This is a cake - {% when "cookie" %} + {% when "cookie", "biscuit" %} This is a cookie {% else %} This is not a cake nor a cookie From 09e4fef7127c66aa23d8fa5c6af58be26aa78890 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 16:39:10 -0500 Subject: [PATCH 08/18] `slice` can be used with arrays --- _filters/slice.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/_filters/slice.md b/_filters/slice.md index eeb1bb8a0..43e8e7fde 100644 --- a/_filters/slice.md +++ b/_filters/slice.md @@ -1,11 +1,11 @@ --- title: slice -description: Liquid filter that returns a substring from a given position in a string. +description: Liquid filter that returns a substring or item from a given position in a string or array. --- -Returns a substring of 1 character beginning at the index specified by the first argument. An optional second argument specifies the length of the substring to be returned. +Returns a substring of one character or series of array items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of array items to be returned. -String indices are numbered starting from 0. +String or array indices are numbered starting from 0.

Input

```liquid @@ -43,7 +43,23 @@ String indices are numbered starting from 0. {{ "Liquid" | slice: 2, 5 }} ``` -If the first argument is a negative number, the indices are counted from the end of the string: +Here the input value is an array: + +

Input

+```liquid +{% raw %} +{% assign beatles = "John, Paul, George, Ringo" | split: ", " %} +{{ beatles | slice: 1, 2 }} +{% endraw %} +``` + +

Output

+```text +{% assign beatles = "John, Paul, George, Ringo" | split: ", " %} +{{ beatles | slice: 1, 2 }} +``` + +If the first argument is a negative number, the indices are counted from the end of the string.

Input

```liquid From 0f83e333c459493b083ec3c1da2458b2fd6e4781 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:09:17 -0500 Subject: [PATCH 09/18] Ranges can be assigned to variables --- _tags/iteration.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/_tags/iteration.md b/_tags/iteration.md index 1db7709fa..86b64695c 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -129,7 +129,7 @@ Begins the loop at the specified index. ### range -Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers. +Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers, and can be pulled from a variable.

Input

```liquid @@ -139,7 +139,8 @@ Defines a range of numbers to loop through. The range can be defined by both lit {% endfor %} {% assign num = 4 %} -{% for i in (1..num) %} +{% assign range = (1..num) %} +{% for i in range %} {{ i }} {% endfor %} {% endraw %} From fc5d02fe1caea6c508c7ca409c68a97b5939cb5b Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:12:01 -0500 Subject: [PATCH 10/18] `capitalize` also downcases each remaining letter --- _filters/capitalize.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_filters/capitalize.md b/_filters/capitalize.md index 72a461e34..4fd0e76ec 100644 --- a/_filters/capitalize.md +++ b/_filters/capitalize.md @@ -1,9 +1,9 @@ --- title: capitalize -description: Liquid filter that capitalizes the first character of a string. +description: Liquid filter that capitalizes the first character of a string and downcases the remaining characters. --- -Makes the first character of a string capitalized. +Makes the first character of a string capitalized and converts the remaining characters to lowercase.

Input

```liquid @@ -22,11 +22,11 @@ Makes the first character of a string capitalized.

Input

```liquid {% raw %} -{{ "my great title" | capitalize }} +{{ "my GREAT title" | capitalize }} {% endraw %} ```

Output

```text -{{ "my great title" | capitalize }} +{{ "my GREAT title" | capitalize }} ``` From b318616a9796b63bc42e4ecfc700514d4ea8b889 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:07:48 -0500 Subject: [PATCH 11/18] `offset` can have a `continue` value in `for` loops --- _tags/iteration.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/_tags/iteration.md b/_tags/iteration.md index 86b64695c..2a4fc71b2 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -127,6 +127,27 @@ Begins the loop at the specified index. 3 4 5 6 ``` +To start a loop from where the last loop using the same iterator left off, pass the special word `continue`. + +

Input

+```liquid +{% raw %} + +{% for item in array limit: 3 %} + {{ item }} +{% endfor %} +{% for item in array limit: 3 offset: continue %} + {{ item }} +{% endfor %} +{% endraw %} +``` + +

Output

+```text +1 2 3 +4 5 6 +``` + ### range Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers, and can be pulled from a variable. From 1b53edf052cf169c6525532169d442feccc392e6 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:22:15 -0500 Subject: [PATCH 12/18] `default` now has an `allow_false` parameter --- _filters/default.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/_filters/default.md b/_filters/default.md index 5366cb408..552fa5d24 100644 --- a/_filters/default.md +++ b/_filters/default.md @@ -50,3 +50,21 @@ In this example, `product_price` is empty, so the default value is used. {% assign product_price = "" %} {{ product_price | default: 2.99 }} ``` + +### Allowing `false` {%- include version-badge.html version="5.0.0" %} + +To allow variables to return `false` instead of the default value, you can use the `allow_false` parameter. + +

Input

+```liquid +{% raw %} +{% assign display_price = false %} +{{ display_price | default: true, allow_false: true }} +{% endraw %} +``` + +

Output

+```text + +false +``` From fb8432ca16577acdf33c0f2dc3e71f9f28ce2b9d Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:15:17 -0500 Subject: [PATCH 13/18] Mention usage of `empty` and EmptyDrop --- _basics/types.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/_basics/types.md b/_basics/types.md index dd57044b9..84bdc342e 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -3,13 +3,14 @@ title: Types description: An overview of data types in the Liquid template language. --- -Liquid objects can have one of five types: +Liquid objects can be one of six types: - [String](#string) - [Number](#number) - [Boolean](#boolean) - [Nil](#nil) - [Array](#array) +- [EmptyDrop](#emptydrop) You can initialize Liquid variables with the [assign]({{ "/tags/variable/#assign" | prepend: site.baseurl }}) or [capture]({{ "/tags/variable/#capture" | prepend: site.baseurl }}) tags. @@ -124,3 +125,31 @@ Adam You cannot initialize arrays using only Liquid. You can, however, use the [split]({{ "/filters/split/" | prepend: site.baseurl }}) filter to break a string into an array of substrings. + +## EmptyDrop + +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 %} +{% assign variable = "hello" %} +{% assign page_1 = pages[variable] %} +{% assign page_2 = pages["does-not-exist"] %} +{% assign page_3 = pages.this-handle-does-not-exist %} +{% endraw %} +``` + +### Checking for emptiness + +You can check to see if an object exists or not before you access any of its attributes. + +```liquid +{% raw %} +{% unless pages == empty %} +

{{ pages.frontpage.title }}

+
{{ pages.frontpage.content }}
+{% endunless %} +{% endraw %} +``` + +Both empty strings and empty arrays will return `true` if checked for equivalence with `empty`. From c99ddcbfc815c27184dcfe81bdca30d2efad1c50 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:20:21 -0500 Subject: [PATCH 14/18] Fix wrong space characters & hard returns --- _tags/comment.md | 4 +--- _tags/iteration.md | 20 ++++++++++---------- _tags/raw.md | 3 +-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/_tags/comment.md b/_tags/comment.md index 3125ffd5b..4961c00e3 100644 --- a/_tags/comment.md +++ b/_tags/comment.md @@ -3,9 +3,7 @@ title: Comment description: An overview of comments tags in the Liquid template language. --- -Allows you to leave un-rendered code inside a Liquid template. Any text within -the opening and closing `comment` blocks will not be printed, and any Liquid code -within will not be executed. +Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing `comment` blocks will not be printed, and any Liquid code within will not be executed.

Input

```liquid diff --git a/_tags/iteration.md b/_tags/iteration.md index 2a4fc71b2..27dcdf6c5 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -99,7 +99,7 @@ Limits the loop to the specified number of iterations. {% for item in array limit:2 %} {{ item }} -{% endfor %} +{% endfor %} {% endraw %} ``` @@ -118,7 +118,7 @@ Begins the loop at the specified index. {% for item in array offset:2 %} {{ item }} -{% endfor %} +{% endfor %} {% endraw %} ``` @@ -155,15 +155,15 @@ Defines a range of numbers to loop through. The range can be defined by both lit

Input

```liquid {% raw %} -{% for i in (3..5) %} +{% for i in (3..5) %} {{ i }} -{% endfor %} +{% endfor %} {% assign num = 4 %} {% assign range = (1..num) %} {% for i in range %} {{ i }} -{% endfor %} +{% endfor %} {% endraw %} ``` @@ -183,7 +183,7 @@ Reverses the order of the loop. Note that this flag's spelling is different from {% for item in array reversed %} {{ item }} -{% endfor %} +{% endfor %} {% endraw %} ``` @@ -363,17 +363,17 @@ Defines a range of numbers to loop through. The range can be defined by both lit {% assign num = 4 %} -{% tablerow i in (1..num) %} +{% tablerow i in (1..num) %} {{ i }} -{% endtablerow %} +{% endtablerow %}
-{% tablerow i in (3..5) %} +{% tablerow i in (3..5) %} {{ i }} -{% endtablerow %} +{% endtablerow %}
{% endraw %} ``` diff --git a/_tags/raw.md b/_tags/raw.md index 610b3296f..668cd4d54 100644 --- a/_tags/raw.md +++ b/_tags/raw.md @@ -3,8 +3,7 @@ title: Raw description: An overview of raw tags in the Liquid template language. --- -Raw temporarily disables tag processing. This is useful for generating content -(eg, Mustache, Handlebars) which uses conflicting syntax. +Temporarily disables tag processing. This is useful for generating certain content (eg, Mustache, Handlebars) that uses conflicting syntax.

Input

```liquid From c2fab68b85003d836c0c659e935a12394b734b5d Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 17:27:23 -0500 Subject: [PATCH 15/18] Improve wording & formatting --- _basics/introduction.md | 14 ++++++-------- _basics/operators.md | 4 ++-- _basics/truthy-and-falsy.md | 8 ++------ _basics/types.md | 8 +++++--- _filters/abs.md | 2 +- _filters/append.md | 4 ++-- _filters/capitalize.md | 2 +- _filters/ceil.md | 2 +- _filters/concat.md | 2 +- _filters/date.md | 4 ++-- _filters/default.md | 2 +- _filters/floor.md | 2 +- _filters/lstrip.md | 2 +- _filters/newline_to_br.md | 2 +- _filters/prepend.md | 2 +- _filters/reverse.md | 2 +- _filters/rstrip.md | 2 +- _filters/truncate.md | 2 +- _filters/truncatewords.md | 2 +- _filters/uniq.md | 2 +- _filters/url_decode.md | 2 +- _filters/url_encode.md | 2 ++ _tags/comment.md | 2 +- _tags/control-flow.md | 6 ++++-- _tags/iteration.md | 6 +++--- _tags/raw.md | 2 +- _tags/variable.md | 14 +++++++------- 27 files changed, 52 insertions(+), 52 deletions(-) diff --git a/_basics/introduction.md b/_basics/introduction.md index 639bb64c6..101affcf6 100644 --- a/_basics/introduction.md +++ b/_basics/introduction.md @@ -4,11 +4,11 @@ description: An overview of objects, tags, and filters in the Liquid template la redirect_from: /basics/ --- -Liquid code can be categorized into [**objects**](#objects), [**tags**](#tags), and [**filters**](#filters). +Liquid uses a combination of [**objects**](#objects), [**tags**](#tags), and [**filters**](#filters) inside **template files** to display dynamic content. ## Objects -**Objects** tell Liquid where to show content on a page. Objects and variable names are denoted by double curly braces: `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`. +**Objects** contain the content that Liquid displays on a page. Objects and variables are displayed when enclosed in double curly braces: `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`.

Input

```liquid @@ -26,9 +26,7 @@ In this case, Liquid is rendering the content of the `title` property of the `pa ## Tags -**Tags** create the logic and control flow for templates. They are denoted by curly braces and percent signs: `{% raw %}{%{% endraw %}` and `{% raw %}%}{% endraw %}`. - -The markup used in tags does not produce any visible text. This means that you can assign variables and create conditions and loops without showing any of the Liquid logic on the page. +**Tags** create the logic and control flow for templates. The curly brace percentage delimiters `{% raw %}{%{% endraw %}` and `{% raw %}%}{% endraw %}` and the text that they surround do not produce any visible output when the template is rendered. This lets you assign variables and create conditions or loops without showing any of the Liquid logic on the page.

Input

```liquid @@ -44,11 +42,11 @@ The markup used in tags does not produce any visible text. This means that you c Hello Adam! ``` -Tags can be categorized into three types: +Tags can be categorized into various types: - [Control flow]({{ "/tags/control-flow/" | prepend: site.baseurl }}) - [Iteration]({{ "/tags/iteration/" | prepend: site.baseurl }}) -- [Variable assignments]({{ "/tags/variable/" | prepend: site.baseurl }}) +- [Variable assignment]({{ "/tags/variable/" | prepend: site.baseurl }}) You can read more about each type of tag in their respective sections. @@ -68,7 +66,7 @@ You can read more about each type of tag in their respective sections. {{ "/my/fancy/url" | append: ".html" }} ``` -Multiple filters can be used on one output. They are applied from left to right. +Multiple filters can be used on one output, and are applied from left to right.

Input

```liquid diff --git a/_basics/operators.md b/_basics/operators.md index 0f945cfe5..05e175969 100644 --- a/_basics/operators.md +++ b/_basics/operators.md @@ -3,7 +3,7 @@ title: Operators description: Using operators to perform calculations in the Liquid template language. --- -Liquid includes many logical and comparison operators. +Liquid includes many logical and comparison operators. You can use operators to create logic with [control flow]({{ "/tags/control-flow/" | prepend: site.baseurl }}) tags. ## Basic operators @@ -54,7 +54,7 @@ For example: {% endraw %} ``` -You can use multiple operators in a tag: +You can do multiple comparisons in a tag using the `and` and `or` operators: ```liquid {% raw %} diff --git a/_basics/truthy-and-falsy.md b/_basics/truthy-and-falsy.md index 5703691d2..cc367f0d2 100644 --- a/_basics/truthy-and-falsy.md +++ b/_basics/truthy-and-falsy.md @@ -3,11 +3,7 @@ title: Truthy and falsy description: An overview of boolean logic in the Liquid template language. --- -In programming, anything that returns `true` in a conditional is called **truthy**. Anything that returns `false` in a conditional is called **falsy**. All object types can be described as either truthy or falsy. - -- [Truthy](#truthy) -- [Falsy](#falsy) -- [Summary](#summary) +When a non-boolean [data type]({{ "/basics/types/" | prepend: site.baseurl }}) is used in a boolean context (such as a conditional tag), Liquid decides whether to evaluate it as `true` or `false`. Data types that return `true` by default are called **truthy**. Data types that return false by default are called **falsy**. ## Truthy @@ -43,7 +39,7 @@ In the example below, the text "Tobi" is not a boolean, but it is truthy in a co ## Falsy -The falsy values in Liquid are [`nil`]({{ "/basics/types/#nil" | prepend: site.baseurl }}) and [`false`]({{ "/basics/types/#boolean" | prepend: site.baseurl }}). +The only values that are falsy in Liquid are [`nil`]({{ "/basics/types/#nil" | prepend: site.baseurl }}) and [`false`]({{ "/basics/types/#boolean" | prepend: site.baseurl }}). ## Summary diff --git a/_basics/types.md b/_basics/types.md index 84bdc342e..6ec4e8c38 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -12,11 +12,11 @@ Liquid objects can be one of six types: - [Array](#array) - [EmptyDrop](#emptydrop) -You can initialize Liquid variables with the [assign]({{ "/tags/variable/#assign" | prepend: site.baseurl }}) or [capture]({{ "/tags/variable/#capture" | prepend: site.baseurl }}) tags. +You can initialize Liquid variables using [`assign`]({{ "/tags/variable/#assign" | prepend: site.baseurl }}) or [`capture`]({{ "/tags/variable/#capture" | prepend: site.baseurl }}) tags. ## String -Declare a string by wrapping a variable's value in single or double quotes: +Strings are sequences of characters wrapped in single or double quotes: ```liquid {% raw %} @@ -24,6 +24,8 @@ Declare a string by wrapping a variable's value in single or double quotes: {% endraw %} ``` +Liquid does not convert escape sequences into special characters. + ## Number Numbers include floats and integers: @@ -124,7 +126,7 @@ Adam You cannot initialize arrays using only Liquid. -You can, however, use the [split]({{ "/filters/split/" | prepend: site.baseurl }}) filter to break a string into an array of substrings. +You can, however, use the [`split`]({{ "/filters/split/" | prepend: site.baseurl }}) filter to break a string into an array of substrings. ## EmptyDrop diff --git a/_filters/abs.md b/_filters/abs.md index 5fc06463d..808551a77 100644 --- a/_filters/abs.md +++ b/_filters/abs.md @@ -20,7 +20,7 @@ Returns the absolute value of a number. {{ 4 | abs }} ``` -`abs` will also work on a string that only contains a number: +`abs` will also work on a string that only contains a number.

Input

```liquid diff --git a/_filters/append.md b/_filters/append.md index 9c0bc1626..f2073d854 100644 --- a/_filters/append.md +++ b/_filters/append.md @@ -3,7 +3,7 @@ title: append description: Liquid filter that appends a string to another string. --- -Concatenates two strings and returns the concatenated value. +Adds the specified string to the end of another string.

Input

```liquid @@ -17,7 +17,7 @@ Concatenates two strings and returns the concatenated value. {{ "/my/fancy/url" | append: ".html" }} ``` -`append` can also be used with variables: +`append` can also accept a variable as its argument.

Input

```liquid diff --git a/_filters/capitalize.md b/_filters/capitalize.md index 4fd0e76ec..7fb1a4939 100644 --- a/_filters/capitalize.md +++ b/_filters/capitalize.md @@ -17,7 +17,7 @@ Makes the first character of a string capitalized and converts the remaining cha {{ "title" | capitalize }} ``` -`capitalize` only capitalizes the first character of a string, so later words are not affected: +Only the first character of a string is capitalized, so later words are not capitalized:

Input

```liquid diff --git a/_filters/ceil.md b/_filters/ceil.md index 825519fee..7dedd17fb 100644 --- a/_filters/ceil.md +++ b/_filters/ceil.md @@ -3,7 +3,7 @@ title: ceil description: Liquid filter that returns the ceiling of a number by rounding up to the nearest integer. --- -Rounds the input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied. +Rounds an input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

Input

```liquid diff --git a/_filters/concat.md b/_filters/concat.md index 18a9b4479..3df9caaf8 100644 --- a/_filters/concat.md +++ b/_filters/concat.md @@ -30,7 +30,7 @@ Concatenates (joins together) multiple arrays. The resulting array contains all - potatoes ``` -You can string together `concat` filters to join more than two arrays: +You can string together multiple `concat` filters to join more than two arrays.

Input

```liquid diff --git a/_filters/date.md b/_filters/date.md index 69be3ec37..4b8a61247 100644 --- a/_filters/date.md +++ b/_filters/date.md @@ -29,7 +29,7 @@ Fri, Jul 17, 15 2015 ``` -`date` works on strings if they contain well-formatted dates: +`date` works on strings if they contain well-formatted dates.

Input

```liquid @@ -43,7 +43,7 @@ Fri, Jul 17, 15 {{ "March 14, 2016" | date: "%b %d, %y" }} ``` -To get the current time, pass the special word `"now"` (or `"today"`) to `date`: +To get the current time, pass the special word `"now"` (or `"today"`) to `date`.

Input

```liquid diff --git a/_filters/default.md b/_filters/default.md index 552fa5d24..123b12b3f 100644 --- a/_filters/default.md +++ b/_filters/default.md @@ -3,7 +3,7 @@ title: default description: Liquid filter that specifies a fallback in case a value doesn't exist. --- -Allows you to specify a fallback in case a value doesn't exist. `default` will show its value if the left side is `nil`, `false`, or empty. +Sets a default value for any variable with no assigned value. `default` will show its value if the input is `nil`, `false`, or empty. In this example, `product_price` is not defined, so the default value is used. diff --git a/_filters/floor.md b/_filters/floor.md index c70a22341..90c5cf63d 100644 --- a/_filters/floor.md +++ b/_filters/floor.md @@ -3,7 +3,7 @@ title: floor description: Liquid filter that returns the floor of a number by rounding down to the nearest integer. --- -Rounds the input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied. +Rounds an input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.

Input

```liquid diff --git a/_filters/lstrip.md b/_filters/lstrip.md index b2fd5a58f..944118b26 100644 --- a/_filters/lstrip.md +++ b/_filters/lstrip.md @@ -3,7 +3,7 @@ title: lstrip description: Liquid filter that removes all whitespace from the left side of a string. --- -Removes all whitespace (tabs, spaces, and newlines) from the left side of a string. It does not affect spaces between words. +Removes all whitespace (tabs, spaces, and newlines) from the **left** side of a string. It does not affect spaces between words.

Input

```liquid diff --git a/_filters/newline_to_br.md b/_filters/newline_to_br.md index 89b280d09..033c4d19f 100644 --- a/_filters/newline_to_br.md +++ b/_filters/newline_to_br.md @@ -3,7 +3,7 @@ title: newline_to_br description: Liquid filter that converts newlines in a string to HTML
tags. --- -Replaces every newline (`\n`) in a string with an HTML line break (`
`). +Inserts an HTML line break (`
`) in front of each newline (`\n`) in a string.

Input

```liquid diff --git a/_filters/prepend.md b/_filters/prepend.md index 5df4708ba..ad6b362ed 100644 --- a/_filters/prepend.md +++ b/_filters/prepend.md @@ -17,7 +17,7 @@ Adds the specified string to the beginning of another string. {{ "apples, oranges, and bananas" | prepend: "Some fruit: " }} ``` -`prepend` can also be used with variables: +`prepend` can also accept a variable as its argument.

Input

```liquid diff --git a/_filters/reverse.md b/_filters/reverse.md index 3832f67c2..4da95ca4a 100644 --- a/_filters/reverse.md +++ b/_filters/reverse.md @@ -21,7 +21,7 @@ Reverses the order of the items in an array. `reverse` cannot reverse a string. {{ my_array | reverse | join: ", " }} ``` -Although `reverse` cannot be used directly on a string, you can split a string into an array, reverse the array, and rejoin it by chaining together filters: +Although `reverse` cannot be used directly on a string, you can split a string into an array, reverse the array, and rejoin it by chaining together filters.

Input

```liquid diff --git a/_filters/rstrip.md b/_filters/rstrip.md index eb8657448..99d913c5d 100644 --- a/_filters/rstrip.md +++ b/_filters/rstrip.md @@ -3,7 +3,7 @@ title: rstrip description: Liquid filter that removes all whitespace from the right side of a string. --- -Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between words. +Removes all whitespace (tabs, spaces, and newlines) from the **right** side of a string. It does not affect spaces between words.

Input

```liquid diff --git a/_filters/truncate.md b/_filters/truncate.md index c0b0a4e39..7b192dc73 100644 --- a/_filters/truncate.md +++ b/_filters/truncate.md @@ -37,7 +37,7 @@ The length of the second argument counts against the number of characters specif ### No ellipsis -You can truncate to the exact number of characters specified by the first argument and avoid showing trailing characters by passing a blank string as the second argument: +You can truncate to the exact number of characters specified by the first argument and avoid showing trailing characters by passing a blank string as the second argument.

Input

```liquid diff --git a/_filters/truncatewords.md b/_filters/truncatewords.md index 6d5c5ab1a..15d731331 100644 --- a/_filters/truncatewords.md +++ b/_filters/truncatewords.md @@ -35,7 +35,7 @@ Shortens a string down to the number of words passed as an argument. If the spec ### No ellipsis -You can avoid showing trailing characters by passing a blank string as the second argument: +You can avoid showing trailing characters by passing a blank string as the second argument.

Input

```liquid diff --git a/_filters/uniq.md b/_filters/uniq.md index e02b4e9d2..c512da7d9 100644 --- a/_filters/uniq.md +++ b/_filters/uniq.md @@ -3,7 +3,7 @@ title: uniq description: Liquid filter that removes duplicate items from an array. --- -Removes any duplicate elements in an array. +Removes any duplicate items in an array.

Input

```liquid diff --git a/_filters/url_decode.md b/_filters/url_decode.md index e2a7f05f5..5ec572fe7 100644 --- a/_filters/url_decode.md +++ b/_filters/url_decode.md @@ -4,7 +4,7 @@ description: Liquid filter that decodes percent-encoded characters in a string. version-badge: 4.0.0 --- -Decodes a string that has been encoded as a URL or by [url_encode]({{ "/filters/url_encode/" | prepend: site.baseurl }}). +Decodes a string that has been encoded as a URL or by [`url_encode`]({{ "/filters/url_encode/" | prepend: site.baseurl }}).

Input

```liquid diff --git a/_filters/url_encode.md b/_filters/url_encode.md index 5a17c8130..b07af5b0e 100644 --- a/_filters/url_encode.md +++ b/_filters/url_encode.md @@ -17,6 +17,8 @@ Converts any URL-unsafe characters in a string into percent-encoded characters. {{ "john@liquid.com" | url_encode }} ``` +Note that `url_encode` will turn a space into a `+` sign instead of a percent-encoded character. +

Input

```liquid {% raw %} diff --git a/_tags/comment.md b/_tags/comment.md index 4961c00e3..39f2c822e 100644 --- a/_tags/comment.md +++ b/_tags/comment.md @@ -1,6 +1,6 @@ --- title: Comment -description: An overview of comments tags in the Liquid template language. +description: An overview of comment tags in the Liquid template language. --- Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing `comment` blocks will not be printed, and any Liquid code within will not be executed. diff --git a/_tags/control-flow.md b/_tags/control-flow.md index 3a99343ed..6a6bfc3e3 100644 --- a/_tags/control-flow.md +++ b/_tags/control-flow.md @@ -4,7 +4,7 @@ description: An overview of control flow and conditional tags in the Liquid temp redirect_from: /tags/ --- -Control flow tags can change the information Liquid shows using programming logic. +Control flow tags create conditions that decide whether blocks of Liquid code get executed. ## if @@ -77,7 +77,9 @@ Hey Anonymous! ## case/when -Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` compares its values. +Creates a switch statement to execute a particular block of code when a variable has a specified value. `case` initializes the switch statement, and `when` statements define the various conditions. + +An optional `else` statement at the end of the case provides code to execute if none of the conditions are met.

Input

```liquid diff --git a/_tags/iteration.md b/_tags/iteration.md index 27dcdf6c5..ea069598f 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -3,7 +3,7 @@ title: Iteration description: An overview of iteration or "loop" tags in the Liquid template language. --- -Iteration tags run blocks of code repeatedly. +Iteration tags repeatedly run blocks of code. ## for @@ -331,7 +331,7 @@ Defines how many columns the tables should have. #### limit -Exits the tablerow after a specific index. +Exits the `tablerow` loop after a specific index. ```liquid {% raw %} @@ -343,7 +343,7 @@ Exits the tablerow after a specific index. ### offset -Starts the tablerow after a specific index. +Starts the `tablerow` loop after a specific index. ```liquid {% raw %} diff --git a/_tags/raw.md b/_tags/raw.md index 668cd4d54..7a0e62d27 100644 --- a/_tags/raw.md +++ b/_tags/raw.md @@ -3,7 +3,7 @@ title: Raw description: An overview of raw tags in the Liquid template language. --- -Temporarily disables tag processing. This is useful for generating certain content (eg, Mustache, Handlebars) that uses conflicting syntax. +Temporarily disables tag processing. This is useful for generating certain content that uses conflicting syntax, such as [Mustache](https://mustache.github.io/) or [Handlebars](https://handlebarsjs.com/).

Input

```liquid diff --git a/_tags/variable.md b/_tags/variable.md index 76124bb51..3c8f4ca39 100644 --- a/_tags/variable.md +++ b/_tags/variable.md @@ -7,7 +7,7 @@ Variable tags create new Liquid variables. ## assign -Creates a new variable. +Creates a new named variable.

Input

```liquid @@ -24,7 +24,7 @@ Creates a new variable. This statement is valid. ``` -Wrap a variable value in quotations `"` to save it as a string. +Wrap a value in quotations `"` to save it as a string variable.

Input

```liquid @@ -42,7 +42,7 @@ Wrap a variable value in quotations `"` to save it as a string. ## capture -Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created through `capture` are strings. +Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created using `capture` are stored as strings.

Input

```liquid @@ -57,7 +57,7 @@ Captures the string inside of the opening and closing tags and assigns it to a v I am being captured. ``` -Using `capture`, you can create complex strings using other variables created with `assign`: +Using `capture`, you can create complex strings using other variables created with `assign`.

Input

```liquid @@ -98,9 +98,9 @@ Creates and outputs a new number variable with initial value `0`. On subsequent {% increment my_counter %} ``` -Variables created through the `increment` tag are independent from variables created through `assign` or `capture`. +Variables created using `increment` are independent from variables created using `assign` or `capture`. -In the example below, a variable named "var" is created through `assign`. The `increment` tag is then used several times on a variable with the same name. Note that the `increment` tag does not affect the value of "var" that was created through `assign`. +In the example below, a variable named "var" is created using `assign`. The `increment` tag is then used several times on a variable with the same name. Note that the `increment` tag does not affect the value of "var" that was created using `assign`.

Input

```liquid @@ -142,4 +142,4 @@ Creates and outputs a new number variable with initial value `-1`. On subsequent {% decrement variable %} ``` -Like [increment](#increment), variables declared inside `decrement` are independent from variables created through `assign` or `capture`. +Like [increment](#increment), variables declared using `decrement` are independent from variables created using `assign` or `capture`. From d8f5d65e327b18acd41c1ea974fe8dc3a0f3aa39 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Thu, 22 Apr 2021 10:33:38 -0400 Subject: [PATCH 16/18] Avoid anchor name conflict with introduction page --- _includes/sidebar.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/sidebar.html b/_includes/sidebar.html index c25858267..b2b979a5f 100644 --- a/_includes/sidebar.html +++ b/_includes/sidebar.html @@ -12,7 +12,7 @@ - \ No newline at end of file + From 77c2dfa989b14a9f1e1ef7ad95829adb6d156e3a Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Mon, 22 Feb 2021 18:00:22 -0500 Subject: [PATCH 17/18] Add new Template page for comment, raw, liquid, echo, render, include --- _basics/introduction.md | 1 + _tags/comment.md | 20 ----- _tags/raw.md | 20 ----- _tags/template.md | 172 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 173 insertions(+), 40 deletions(-) delete mode 100644 _tags/comment.md delete mode 100644 _tags/raw.md create mode 100644 _tags/template.md diff --git a/_basics/introduction.md b/_basics/introduction.md index 101affcf6..0ed78cc47 100644 --- a/_basics/introduction.md +++ b/_basics/introduction.md @@ -46,6 +46,7 @@ Tags can be categorized into various types: - [Control flow]({{ "/tags/control-flow/" | prepend: site.baseurl }}) - [Iteration]({{ "/tags/iteration/" | prepend: site.baseurl }}) +- [Template]({{ "/tags/template/" | prepend: site.baseurl }}) - [Variable assignment]({{ "/tags/variable/" | prepend: site.baseurl }}) You can read more about each type of tag in their respective sections. diff --git a/_tags/comment.md b/_tags/comment.md deleted file mode 100644 index 39f2c822e..000000000 --- a/_tags/comment.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Comment -description: An overview of comment tags in the Liquid template language. ---- - -Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing `comment` blocks will not be printed, and any Liquid code within will not be executed. - -

Input

-```liquid -{% raw %} -Anything you put between {% comment %} and {% endcomment %} tags -is turned into a comment. -{% endraw %} -``` - -

Output

-```liquid -Anything you put between {% comment %} and {% endcomment %} tags -is turned into a comment. -``` diff --git a/_tags/raw.md b/_tags/raw.md deleted file mode 100644 index 7a0e62d27..000000000 --- a/_tags/raw.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Raw -description: An overview of raw tags in the Liquid template language. ---- - -Temporarily disables tag processing. This is useful for generating certain content that uses conflicting syntax, such as [Mustache](https://mustache.github.io/) or [Handlebars](https://handlebarsjs.com/). - -

Input

-```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 %} -``` diff --git a/_tags/template.md b/_tags/template.md new file mode 100644 index 000000000..547411200 --- /dev/null +++ b/_tags/template.md @@ -0,0 +1,172 @@ +--- +title: Template +description: An overview of template tags in the Liquid template language. +redirect_from: + - /tags/comment/ + - /tags/raw/ +--- + +Template tags tell Liquid where to disable processing for comments or non-Liquid markup, and how to establish relations among template files. + +## comment + +Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing `comment` blocks will not be printed, and any Liquid code within will not be executed. + +

Input

+```liquid +{% raw %} +{% assign verb = "turned" %} +{% comment %} +{% assign verb = "converted" %} +{% endcomment %} +Anything you put between {% comment %} and {% endcomment %} tags +is {{ verb }} into a comment. +{% endraw %} +``` + +

Output

+```liquid +{% assign verb = "turned" %} +{% comment %} +{% assign verb = "converted" %} +{% endcomment %} +Anything you put between {% comment %} and {% endcomment %} tags +is {{ verb }} into a comment. +``` + +## raw + +Temporarily disables tag processing. This is useful for generating certain content that uses conflicting syntax, such as [Mustache](https://mustache.github.io/) or [Handlebars](https://handlebarsjs.com/). + +

Input

+```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 %} +``` + +## liquid {%- include version-badge.html version="5.0.0" %} + +Encloses multiple tags within one set of delimiters, to allow writing Liquid logic more concisely. + +```liquid +{% raw %} +{% liquid +case section.blocks.size +when 1 + assign column_size = '' +when 2 + assign column_size = 'one-half' +when 3 + assign column_size = 'one-third' +else + assign column_size = 'one-quarter' +endcase %} +{% endraw %} +``` + +Because any tag blocks opened within a `liquid` tag must also be closed within the same tag, use [`echo`](#echo) to output data. + +## echo {%- include version-badge.html version="5.0.0" %} + +Outputs an expression in the rendered HTML. This is identical to wrapping an expression in `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`, but works inside [`liquid`](#liquid) tags and supports [filters]({{ "/basics/introduction/#filters" | prepend: site.baseurl }}). + +

Input

+```liquid +{% raw %} +{% liquid +for product in collection.products + echo product.title | capitalize +endfor %} +{% endraw %} +``` + +

Output

+```text +Hat Shirt Pants +``` + +## render {%- include version-badge.html version="5.0.0" %} + +Insert the rendered content of another template within the current template. + +```liquid +{% raw %} +{% render "template-name" %} +{% endraw %} +``` + +Note that you don't need to write the file's `.liquid` extension. + +The code within the rendered template does **not** automatically have access to the variables assigned using [variable tags]({{ "/tags/variable/" | prepend: site.baseurl }}) within the parent template. Similarly, variables assigned within the rendered template cannot be accessed by code in any other template. + +## render (parameters) + +Variables assigned using [variable tags]({{ "/tags/variable/" | prepend: site.baseurl }}) can be passed to a template by listing them as parameters on the `render` tag. + +```liquid +{% raw %} +{% assign my_variable = "apples" %} +{% render "name", my_variable: my_variable, my_other_variable: "oranges" %} +{% endraw %} +``` + +One or more objects can be passed to a template. + +```liquid +{% raw %} +{% assign featured_product = all_products["product_handle"] %} +{% render "product", product: featured_product %} +{% endraw %} +``` + +### with + +A single object can be passed to a template by using the `with` and optional `as` parameters. + +```liquid +{% raw %} +{% assign featured_product = all_products["product_handle"] %} +{% render "product" with featured_product as product %} +{% endraw %} +``` + +In the example above, the `product` variable in the rendered template will hold the value of `featured_product` from the parent template. + +### for + +A template can be rendered once for each value of an enumerable object by using the `for` and optional `as` parameters. + +```liquid +{% raw %} +{% assign variants = product.variants %} +{% render "product_variant" for variants as variant %} +{% endraw %} +``` + +In the example above, the template will be rendered once for each variant of the product, and the `variant` variable will hold a different product variant object for each iteration. + +When using the `for` parameter, the [`forloop`](https://shopify.dev/docs/themes/liquid/reference/objects/for-loops) object is accessible within the rendered template. + +## include + +_The `include` tag is deprecated; please use [`render`](#render) instead._ + +Insert the rendered content of another template within the current template. + +```liquid +{% raw %} +{% include "template-name" %} +{% endraw %} +``` + +The `include` tag works similarly to the [`render`](#render) tag, but it allows the code inside of the rendered template to access and overwrite the variables within its parent template. It has been deprecated because the way that it handles variables reduces performance and makes Liquid code harder to both read and maintain. + +Note that when a template is rendered using the [`render`](#render) tag, the `include` tag cannot be used within the template. From b98d3d60973aa3cdc59bd1ebd541952b6eebb5b2 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Thu, 22 Apr 2021 17:08:46 -0400 Subject: [PATCH 18/18] Drop blank lines from input examples --- _basics/introduction.md | 8 ++++---- _basics/operators.md | 12 ++++++------ _basics/truthy-and-falsy.md | 4 ++-- _basics/types.md | 18 +++++++++--------- _basics/whitespace.md | 8 ++++---- _filters/abs.md | 4 ++-- _filters/append.md | 4 ++-- _filters/at_least.md | 2 +- _filters/at_most.md | 2 +- _filters/capitalize.md | 4 ++-- _filters/ceil.md | 4 ++-- _filters/compact.md | 4 ++-- _filters/concat.md | 4 ++-- _filters/date.md | 8 ++++---- _filters/default.md | 8 ++++---- _filters/divided_by.md | 10 +++++----- _filters/downcase.md | 4 ++-- _filters/escape.md | 4 ++-- _filters/escape_once.md | 4 ++-- _filters/first.md | 6 +++--- _filters/floor.md | 4 ++-- _filters/join.md | 2 +- _filters/last.md | 6 +++--- _filters/lstrip.md | 2 +- _filters/map.md | 2 +- _filters/minus.md | 2 +- _filters/modulo.md | 2 +- _filters/newline_to_br.md | 2 +- _filters/plus.md | 2 +- _filters/prepend.md | 4 ++-- _filters/remove.md | 2 +- _filters/remove_first.md | 2 +- _filters/replace.md | 2 +- _filters/replace_first.md | 2 +- _filters/reverse.md | 4 ++-- _filters/round.md | 2 +- _filters/rstrip.md | 2 +- _filters/size.md | 6 +++--- _filters/slice.md | 10 +++++----- _filters/sort.md | 4 ++-- _filters/sort_natural.md | 4 ++-- _filters/split.md | 2 +- _filters/strip.md | 2 +- _filters/strip_html.md | 2 +- _filters/strip_newlines.md | 2 +- _filters/times.md | 2 +- _filters/truncate.md | 6 +++--- _filters/truncatewords.md | 6 +++--- _filters/uniq.md | 2 +- _filters/upcase.md | 4 ++-- _filters/url_decode.md | 2 +- _filters/url_encode.md | 4 ++-- _filters/where.md | 6 +++--- _tags/control-flow.md | 10 +++++----- _tags/iteration.md | 32 ++++++++++++++++---------------- _tags/template.md | 18 +++++++++--------- _tags/variable.md | 14 +++++++------- 57 files changed, 152 insertions(+), 152 deletions(-) diff --git a/_basics/introduction.md b/_basics/introduction.md index 0ed78cc47..cdf3fd48e 100644 --- a/_basics/introduction.md +++ b/_basics/introduction.md @@ -12,7 +12,7 @@ Liquid uses a combination of [**objects**](#objects), [**tags**](#tags), and [**

Input

```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

Input

```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.

Input

```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.

Input

```liquid -{% raw %} +{%- raw -%} {{ "adam!" | capitalize | prepend: "Hello " }} {% endraw %} ``` diff --git a/_basics/operators.md b/_basics/operators.md index 05e175969..a1858c968 100644 --- a/_basics/operators.md +++ b/_basics/operators.md @@ -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: diff --git a/_basics/truthy-and-falsy.md b/_basics/truthy-and-falsy.md index cc367f0d2..492b7ad5e 100644 --- a/_basics/truthy-and-falsy.md +++ b/_basics/truthy-and-falsy.md @@ -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

Input

```liquid -{% raw %} +{%- raw -%} {% if page.category %}

{{ page.category }}

{% endif %} diff --git a/_basics/types.md b/_basics/types.md index 6ec4e8c38..8c209af53 100644 --- a/_basics/types.md +++ b/_basics/types.md @@ -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.

Input

```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

Input

```liquid -{% raw %} +{%- raw -%} {% for user in site.users %} {{ user }} @@ -107,7 +107,7 @@ You can use square bracket `[` `]` notation to access a specific item in an arra

Input

```liquid -{% raw %} +{%- raw -%} {{ 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 %}

{{ pages.frontpage.title }}

{{ pages.frontpage.content }}
diff --git a/_basics/whitespace.md b/_basics/whitespace.md index 77587bc0e..6059f756a 100644 --- a/_basics/whitespace.md +++ b/_basics/whitespace.md @@ -9,7 +9,7 @@ Normally, even if it doesn't print text, any line of Liquid in your template wil

Input

```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

Input

```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

Input

```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

Input

```liquid -{% raw %} +{%- raw -%} {% assign username = "John G. Chalmers-Smith" -%} {%- if username and username.size > 10 -%} Wow, {{ username -}} , you have a long name! diff --git a/_filters/abs.md b/_filters/abs.md index 808551a77..6763ecc23 100644 --- a/_filters/abs.md +++ b/_filters/abs.md @@ -8,7 +8,7 @@ Returns the absolute value of a number.

Input

```liquid -{% raw %} +{%- raw -%} {{ -17 | abs }} {{ 4 | abs }} {% endraw %} @@ -24,7 +24,7 @@ Returns the absolute value of a number.

Input

```liquid -{% raw %} +{%- raw -%} {{ "-19.86" | abs }} {% endraw %} ``` diff --git a/_filters/append.md b/_filters/append.md index f2073d854..ab8356c9d 100644 --- a/_filters/append.md +++ b/_filters/append.md @@ -7,7 +7,7 @@ Adds the specified string to the end of another string.

Input

```liquid -{% raw %} +{%- raw -%} {{ "/my/fancy/url" | append: ".html" }} {% endraw %} ``` @@ -21,7 +21,7 @@ Adds the specified string to the end of another string.

Input

```liquid -{% raw %} +{%- raw -%} {% assign filename = "/index.html" %} {{ "website.com" | append: filename }} {% endraw %} diff --git a/_filters/at_least.md b/_filters/at_least.md index ab61b36b1..3f23b706c 100644 --- a/_filters/at_least.md +++ b/_filters/at_least.md @@ -8,7 +8,7 @@ Limits a number to a minimum value.

Input

```liquid -{% raw %} +{%- raw -%} {{ 4 | at_least: 5 }} {{ 4 | at_least: 3 }} {% endraw %} diff --git a/_filters/at_most.md b/_filters/at_most.md index f8f208c82..728e7960a 100644 --- a/_filters/at_most.md +++ b/_filters/at_most.md @@ -8,7 +8,7 @@ Limits a number to a maximum value.

Input

```liquid -{% raw %} +{%- raw -%} {{ 4 | at_most: 5 }} {{ 4 | at_most: 3 }} {% endraw %} diff --git a/_filters/capitalize.md b/_filters/capitalize.md index 7fb1a4939..99475e379 100644 --- a/_filters/capitalize.md +++ b/_filters/capitalize.md @@ -7,7 +7,7 @@ Makes the first character of a string capitalized and converts the remaining cha

Input

```liquid -{% raw %} +{%- raw -%} {{ "title" | capitalize }} {% endraw %} ``` @@ -21,7 +21,7 @@ Only the first character of a string is capitalized, so later words are not capi

Input

```liquid -{% raw %} +{%- raw -%} {{ "my GREAT title" | capitalize }} {% endraw %} ``` diff --git a/_filters/ceil.md b/_filters/ceil.md index 7dedd17fb..80c67f3e0 100644 --- a/_filters/ceil.md +++ b/_filters/ceil.md @@ -7,7 +7,7 @@ Rounds an input up to the nearest whole number. Liquid tries to convert the inpu

Input

```liquid -{% raw %} +{%- raw -%} {{ 1.2 | ceil }} {{ 2.0 | ceil }} {{ 183.357 | ceil }} @@ -25,7 +25,7 @@ Here the input value is a string:

Input

```liquid -{% raw %} +{%- raw -%} {{ "3.5" | ceil }} {% endraw %} ``` diff --git a/_filters/compact.md b/_filters/compact.md index d9c307508..174339f42 100644 --- a/_filters/compact.md +++ b/_filters/compact.md @@ -10,7 +10,7 @@ For this example, assume `site.pages` is an array of content pages for a website

Input

```liquid -{% raw %} +{%- raw -%} {% assign site_categories = site.pages | map: "category" %} {% for category in site_categories %} @@ -34,7 +34,7 @@ By using `compact` when we create our `site_categories` array, we can remove all

Input

```liquid -{% raw %} +{%- raw -%} {% assign site_categories = site.pages | map: "category" | compact %} {% for category in site_categories %} diff --git a/_filters/concat.md b/_filters/concat.md index 3df9caaf8..7ce565ad1 100644 --- a/_filters/concat.md +++ b/_filters/concat.md @@ -8,7 +8,7 @@ Concatenates (joins together) multiple arrays. The resulting array contains all

Input

```liquid -{% raw %} +{%- raw -%} {% assign fruits = "apples, oranges, peaches" | split: ", " %} {% assign vegetables = "carrots, turnips, potatoes" | split: ", " %} @@ -34,7 +34,7 @@ You can string together multiple `concat` filters to join more than two arrays.

Input

```liquid -{% raw %} +{%- raw -%} {% assign furniture = "chairs, tables, shelves" | split: ", " %} {% assign everything = fruits | concat: vegetables | concat: furniture %} diff --git a/_filters/date.md b/_filters/date.md index 4b8a61247..cc0b79f18 100644 --- a/_filters/date.md +++ b/_filters/date.md @@ -7,7 +7,7 @@ Converts a timestamp into another date format. The format for this syntax is the

Input

```liquid -{% raw %} +{%- raw -%} {{ article.published_at | date: "%a, %b %d, %y" }} {% endraw %} ``` @@ -19,7 +19,7 @@ Fri, Jul 17, 15

Input

```liquid -{% raw %} +{%- raw -%} {{ article.published_at | date: "%Y" }} {% endraw %} ``` @@ -33,7 +33,7 @@ Fri, Jul 17, 15

Input

```liquid -{% raw %} +{%- raw -%} {{ "March 14, 2016" | date: "%b %d, %y" }} {% endraw %} ``` @@ -47,7 +47,7 @@ To get the current time, pass the special word `"now"` (or `"today"`) to `date`.

Input

```liquid -{% raw %} +{%- raw -%} This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}. {% endraw %} ``` diff --git a/_filters/default.md b/_filters/default.md index 123b12b3f..9231b85b1 100644 --- a/_filters/default.md +++ b/_filters/default.md @@ -9,7 +9,7 @@ In this example, `product_price` is not defined, so the default value is used.

Input

```liquid -{% raw %} +{%- raw -%} {{ product_price | default: 2.99 }} {% endraw %} ``` @@ -23,7 +23,7 @@ In this example, `product_price` is defined, so the default value is not used.

Input

```liquid -{% raw %} +{%- raw -%} {% assign product_price = 4.99 %} {{ product_price | default: 2.99 }} {% endraw %} @@ -39,7 +39,7 @@ In this example, `product_price` is empty, so the default value is used.

Input

```liquid -{% raw %} +{%- raw -%} {% assign product_price = "" %} {{ product_price | default: 2.99 }} {% endraw %} @@ -57,7 +57,7 @@ To allow variables to return `false` instead of the default value, you can use t

Input

```liquid -{% raw %} +{%- raw -%} {% assign display_price = false %} {{ display_price | default: true, allow_false: true }} {% endraw %} diff --git a/_filters/divided_by.md b/_filters/divided_by.md index 500ca5629..72c83db54 100644 --- a/_filters/divided_by.md +++ b/_filters/divided_by.md @@ -9,7 +9,7 @@ The result is rounded down to the nearest integer (that is, the [floor]({{ "/fil

Input

```liquid -{% raw %} +{%- raw -%} {{ 16 | divided_by: 4 }} {{ 5 | divided_by: 3 }} {% endraw %} @@ -29,7 +29,7 @@ For example, here the divisor is an integer:

Input

```liquid -{% raw %} +{%- raw -%} {{ 20 | divided_by: 7 }} {% endraw %} ``` @@ -43,7 +43,7 @@ Here it is a float:

Input

```liquid -{% raw %} +{%- raw -%} {{ 20 | divided_by: 7.0 }} {% endraw %} ``` @@ -61,7 +61,7 @@ In this example, we're dividing by a variable that contains an integer, so we ge

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_integer = 7 %} {{ 20 | divided_by: my_integer }} {% endraw %} @@ -77,7 +77,7 @@ Here, we [multiply]({{ "/filters/times/" | prepend: site.baseurl }}) the variabl

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_integer = 7 %} {% assign my_float = my_integer | times: 1.0 %} {{ 20 | divided_by: my_float }} diff --git a/_filters/downcase.md b/_filters/downcase.md index e66239efb..e73212767 100644 --- a/_filters/downcase.md +++ b/_filters/downcase.md @@ -7,7 +7,7 @@ Makes each character in a string lowercase. It has no effect on strings which ar

Input

```liquid -{% raw %} +{%- raw -%} {{ "Parker Moore" | downcase }} {% endraw %} ``` @@ -19,7 +19,7 @@ Makes each character in a string lowercase. It has no effect on strings which ar

Input

```liquid -{% raw %} +{%- raw -%} {{ "apple" | downcase }} {% endraw %} ``` diff --git a/_filters/escape.md b/_filters/escape.md index 479325b5f..1a7db6119 100644 --- a/_filters/escape.md +++ b/_filters/escape.md @@ -7,7 +7,7 @@ Escapes a string by replacing characters with escape sequences (so that the stri

Input

```liquid -{% raw %} +{%- raw -%} {{ "Have you read 'James & the Giant Peach'?" | escape }} {% endraw %} ``` @@ -19,7 +19,7 @@ Escapes a string by replacing characters with escape sequences (so that the stri

Input

```liquid -{% raw %} +{%- raw -%} {{ "Tetsuro Takara" | escape }} {% endraw %} ``` diff --git a/_filters/escape_once.md b/_filters/escape_once.md index 6ee787ec0..1aa358b24 100644 --- a/_filters/escape_once.md +++ b/_filters/escape_once.md @@ -7,7 +7,7 @@ Escapes a string without changing existing escaped entities. It doesn't change s

Input

```liquid -{% raw %} +{%- raw -%} {{ "1 < 2 & 3" | escape_once }} {% endraw %} ``` @@ -19,7 +19,7 @@ Escapes a string without changing existing escaped entities. It doesn't change s

Input

```liquid -{% raw %} +{%- raw -%} {{ "1 < 2 & 3" | escape_once }} {% endraw %} ``` diff --git a/_filters/first.md b/_filters/first.md index a5345975b..386975da9 100644 --- a/_filters/first.md +++ b/_filters/first.md @@ -7,7 +7,7 @@ Returns the first item of an array.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | split: " " | first }} {% endraw %} ``` @@ -19,7 +19,7 @@ Returns the first item of an array.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} {{ my_array.first }} @@ -36,7 +36,7 @@ Returns the first item of an array. You can use `first` with dot notation when you need to use the filter inside a tag: ```liquid -{% raw %} +{%- raw -%} {% if my_array.first == "zebra" %} Here comes a zebra! {% endif %} diff --git a/_filters/floor.md b/_filters/floor.md index 90c5cf63d..70ea9c9b1 100644 --- a/_filters/floor.md +++ b/_filters/floor.md @@ -7,7 +7,7 @@ Rounds an input down to the nearest whole number. Liquid tries to convert the in

Input

```liquid -{% raw %} +{%- raw -%} {{ 1.2 | floor }} {{ 2.0 | floor }} {{ 183.357 | floor }} @@ -25,7 +25,7 @@ Here the input value is a string:

Input

```liquid -{% raw %} +{%- raw -%} {{ "3.5" | floor }} {% endraw %} ``` diff --git a/_filters/join.md b/_filters/join.md index 2cd589ce3..1e3391bce 100644 --- a/_filters/join.md +++ b/_filters/join.md @@ -7,7 +7,7 @@ Combines the items in an array into a single string using the argument as a sepa

Input

```liquid -{% raw %} +{%- raw -%} {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} {{ beatles | join: " and " }} diff --git a/_filters/last.md b/_filters/last.md index 5337abbed..7d3c911f1 100644 --- a/_filters/last.md +++ b/_filters/last.md @@ -7,7 +7,7 @@ Returns the last item of an array.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | split: " " | last }} {% endraw %} ``` @@ -19,7 +19,7 @@ Returns the last item of an array.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} {{ my_array.last }} @@ -36,7 +36,7 @@ Returns the last item of an array. You can use `last` with dot notation when you need to use the filter inside a tag: ```liquid -{% raw %} +{%- raw -%} {% if my_array.last == "tiger" %} There goes a tiger! {% endif %} diff --git a/_filters/lstrip.md b/_filters/lstrip.md index 944118b26..df7ec6ead 100644 --- a/_filters/lstrip.md +++ b/_filters/lstrip.md @@ -7,7 +7,7 @@ Removes all whitespace (tabs, spaces, and newlines) from the **left** side of a

Input

```liquid -{% raw %} +{%- raw -%} {{ " So much room for activities " | lstrip }}! {% endraw %} ``` diff --git a/_filters/map.md b/_filters/map.md index ddeff2014..62e754d83 100644 --- a/_filters/map.md +++ b/_filters/map.md @@ -9,7 +9,7 @@ In this example, assume the object `site.pages` contains all the metadata for a

Input

```liquid -{% raw %} +{%- raw -%} {% assign all_categories = site.pages | map: "category" %} {% for item in all_categories %} diff --git a/_filters/minus.md b/_filters/minus.md index 60963ec4e..53232939a 100644 --- a/_filters/minus.md +++ b/_filters/minus.md @@ -7,7 +7,7 @@ Subtracts a number from another number.

Input

```liquid -{% raw %} +{%- raw -%} {{ 4 | minus: 2 }} {{ 16 | minus: 4 }} {{ 183.357 | minus: 12 }} diff --git a/_filters/modulo.md b/_filters/modulo.md index f71c3dc0f..b0de01a02 100644 --- a/_filters/modulo.md +++ b/_filters/modulo.md @@ -7,7 +7,7 @@ Returns the remainder of a division operation.

Input

```liquid -{% raw %} +{%- raw -%} {{ 3 | modulo: 2 }} {{ 24 | modulo: 7 }} {{ 183.357 | modulo: 12 }} diff --git a/_filters/newline_to_br.md b/_filters/newline_to_br.md index 033c4d19f..70b197451 100644 --- a/_filters/newline_to_br.md +++ b/_filters/newline_to_br.md @@ -7,7 +7,7 @@ Inserts an HTML line break (`
`) in front of each newline (`\n`) in a strin

Input

```liquid -{% raw %} +{%- raw -%} {% capture string_with_newlines %} Hello there diff --git a/_filters/plus.md b/_filters/plus.md index a67794075..039f22189 100644 --- a/_filters/plus.md +++ b/_filters/plus.md @@ -7,7 +7,7 @@ Adds a number to another number.

Input

```liquid -{% raw %} +{%- raw -%} {{ 4 | plus: 2 }} {{ 16 | plus: 4 }} {{ 183.357 | plus: 12 }} diff --git a/_filters/prepend.md b/_filters/prepend.md index ad6b362ed..6d39521e3 100644 --- a/_filters/prepend.md +++ b/_filters/prepend.md @@ -7,7 +7,7 @@ Adds the specified string to the beginning of another string.

Input

```liquid -{% raw %} +{%- raw -%} {{ "apples, oranges, and bananas" | prepend: "Some fruit: " }} {% endraw %} ``` @@ -21,7 +21,7 @@ Adds the specified string to the beginning of another string.

Input

```liquid -{% raw %} +{%- raw -%} {% assign url = "example.com" %} {{ "/index.html" | prepend: url }} {% endraw %} diff --git a/_filters/remove.md b/_filters/remove.md index 0a294abac..8349b0b6e 100644 --- a/_filters/remove.md +++ b/_filters/remove.md @@ -7,7 +7,7 @@ Removes every occurrence of the specified substring from a string.

Input

```liquid -{% raw %} +{%- raw -%} {{ "I strained to see the train through the rain" | remove: "rain" }} {% endraw %} ``` diff --git a/_filters/remove_first.md b/_filters/remove_first.md index ead16b95e..4c659171f 100644 --- a/_filters/remove_first.md +++ b/_filters/remove_first.md @@ -7,7 +7,7 @@ Removes only the first occurrence of the specified substring from a string.

Input

```liquid -{% raw %} +{%- raw -%} {{ "I strained to see the train through the rain" | remove_first: "rain" }} {% endraw %} ``` diff --git a/_filters/replace.md b/_filters/replace.md index aba612f97..3fde134b6 100644 --- a/_filters/replace.md +++ b/_filters/replace.md @@ -7,7 +7,7 @@ Replaces every occurrence of the first argument in a string with the second argu

Input

```liquid -{% raw %} +{%- raw -%} {{ "Take my protein pills and put my helmet on" | replace: "my", "your" }} {% endraw %} ``` diff --git a/_filters/replace_first.md b/_filters/replace_first.md index c25ee3ac8..5c46ac431 100644 --- a/_filters/replace_first.md +++ b/_filters/replace_first.md @@ -7,7 +7,7 @@ Replaces only the first occurrence of the first argument in a string with the se

Input

```liquid -{% raw %} +{%- raw -%} {{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }} {% endraw %} ``` diff --git a/_filters/reverse.md b/_filters/reverse.md index 4da95ca4a..b7d88bc68 100644 --- a/_filters/reverse.md +++ b/_filters/reverse.md @@ -7,7 +7,7 @@ Reverses the order of the items in an array. `reverse` cannot reverse a string.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} {{ my_array | reverse | join: ", " }} @@ -25,7 +25,7 @@ Although `reverse` cannot be used directly on a string, you can split a string i

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | split: "" | reverse | join: "" }} {% endraw %} ``` diff --git a/_filters/round.md b/_filters/round.md index 7050fbd1c..6eb2e655a 100644 --- a/_filters/round.md +++ b/_filters/round.md @@ -7,7 +7,7 @@ Rounds a number to the nearest integer or, if a number is passed as an argument,

Input

```liquid -{% raw %} +{%- raw -%} {{ 1.2 | round }} {{ 2.7 | round }} {{ 183.357 | round: 2 }} diff --git a/_filters/rstrip.md b/_filters/rstrip.md index 99d913c5d..5226dd977 100644 --- a/_filters/rstrip.md +++ b/_filters/rstrip.md @@ -7,7 +7,7 @@ Removes all whitespace (tabs, spaces, and newlines) from the **right** side of a

Input

```liquid -{% raw %} +{%- raw -%} {{ " So much room for activities " | rstrip }}! {% endraw %} ``` diff --git a/_filters/size.md b/_filters/size.md index 96d8a096a..4d50dfc58 100644 --- a/_filters/size.md +++ b/_filters/size.md @@ -7,7 +7,7 @@ Returns the number of characters in a string or the number of items in an array.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | size }} {% endraw %} ``` @@ -19,7 +19,7 @@ Returns the number of characters in a string or the number of items in an array.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} {{ my_array.size }} @@ -36,7 +36,7 @@ Returns the number of characters in a string or the number of items in an array. You can use `size` with dot notation when you need to use the filter inside a tag: ```liquid -{% raw %} +{%- raw -%} {% if site.pages.size > 10 %} This is a big website! {% endif %} diff --git a/_filters/slice.md b/_filters/slice.md index 43e8e7fde..2f6c70482 100644 --- a/_filters/slice.md +++ b/_filters/slice.md @@ -9,7 +9,7 @@ String or array indices are numbered starting from 0.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Liquid" | slice: 0 }} {% endraw %} ``` @@ -21,7 +21,7 @@ String or array indices are numbered starting from 0.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Liquid" | slice: 2 }} {% endraw %} ``` @@ -33,7 +33,7 @@ String or array indices are numbered starting from 0.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Liquid" | slice: 2, 5 }} {% endraw %} ``` @@ -47,7 +47,7 @@ Here the input value is an array:

Input

```liquid -{% raw %} +{%- raw -%} {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} {{ beatles | slice: 1, 2 }} {% endraw %} @@ -63,7 +63,7 @@ If the first argument is a negative number, the indices are counted from the end

Input

```liquid -{% raw %} +{%- raw -%} {{ "Liquid" | slice: -3, 2 }} {% endraw %} ``` diff --git a/_filters/sort.md b/_filters/sort.md index f890d5cef..72f0a9998 100644 --- a/_filters/sort.md +++ b/_filters/sort.md @@ -7,7 +7,7 @@ Sorts items in an array in case-sensitive order.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %} {{ my_array | sort | join: ", " }} @@ -24,7 +24,7 @@ Sorts items in an array in case-sensitive order. An optional argument specifies which property of the array's items to use for sorting. ```liquid -{% raw %} +{%- raw -%} {% assign products_by_price = collection.products | sort: "price" %} {% for product in products_by_price %}

{{ product.title }}

diff --git a/_filters/sort_natural.md b/_filters/sort_natural.md index dadeac733..233efc01f 100644 --- a/_filters/sort_natural.md +++ b/_filters/sort_natural.md @@ -8,7 +8,7 @@ Sorts items in an array in case-insensitive order.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %} {{ my_array | sort_natural | join: ", " }} @@ -25,7 +25,7 @@ Sorts items in an array in case-insensitive order. An optional argument specifies which property of the array's items to use for sorting. ```liquid -{% raw %} +{%- raw -%} {% assign products_by_company = collection.products | sort_natural: "company" %} {% for product in products_by_company %}

{{ product.title }}

diff --git a/_filters/split.md b/_filters/split.md index 40ebae69d..c7e8ee463 100644 --- a/_filters/split.md +++ b/_filters/split.md @@ -7,7 +7,7 @@ Divides a string into an array using the argument as a separator. `split` is com

Input

```liquid -{% raw %} +{%- raw -%} {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} {% for member in beatles %} diff --git a/_filters/strip.md b/_filters/strip.md index 59d240254..a79816a63 100644 --- a/_filters/strip.md +++ b/_filters/strip.md @@ -7,7 +7,7 @@ Removes all whitespace (tabs, spaces, and newlines) from both the left and right

Input

```liquid -{% raw %} +{%- raw -%} {{ " So much room for activities " | strip }}! {% endraw %} ``` diff --git a/_filters/strip_html.md b/_filters/strip_html.md index 9ca00f086..88425993b 100644 --- a/_filters/strip_html.md +++ b/_filters/strip_html.md @@ -7,7 +7,7 @@ Removes any HTML tags from a string.

Input

```liquid -{% raw %} +{%- raw -%} {{ "Have you read Ulysses?" | strip_html }} {% endraw %} ``` diff --git a/_filters/strip_newlines.md b/_filters/strip_newlines.md index c05deaa36..0a2324bb2 100644 --- a/_filters/strip_newlines.md +++ b/_filters/strip_newlines.md @@ -7,7 +7,7 @@ Removes any newline characters (line breaks) from a string.

Input

```liquid -{% raw %} +{%- raw -%} {% capture string_with_newlines %} Hello there diff --git a/_filters/times.md b/_filters/times.md index 8863996fa..90c2757a4 100644 --- a/_filters/times.md +++ b/_filters/times.md @@ -7,7 +7,7 @@ Multiplies a number by another number.

Input

```liquid -{% raw %} +{%- raw -%} {{ 3 | times: 2 }} {{ 24 | times: 7 }} {{ 183.357 | times: 12 }} diff --git a/_filters/truncate.md b/_filters/truncate.md index 7b192dc73..0881fb08f 100644 --- a/_filters/truncate.md +++ b/_filters/truncate.md @@ -7,7 +7,7 @@ Shortens a string down to the number of characters passed as an argument. If the

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | truncate: 20 }} {% endraw %} ``` @@ -25,7 +25,7 @@ The length of the second argument counts against the number of characters specif

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | truncate: 25, ", and so on" }} {% endraw %} ``` @@ -41,7 +41,7 @@ You can truncate to the exact number of characters specified by the first argume

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | truncate: 20, "" }} {% endraw %} ``` diff --git a/_filters/truncatewords.md b/_filters/truncatewords.md index 15d731331..5cc57a5b6 100644 --- a/_filters/truncatewords.md +++ b/_filters/truncatewords.md @@ -7,7 +7,7 @@ Shortens a string down to the number of words passed as an argument. If the spec

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | truncatewords: 3 }} {% endraw %} ``` @@ -23,7 +23,7 @@ Shortens a string down to the number of words passed as an argument. If the spec

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | truncatewords: 3, "--" }} {% endraw %} ``` @@ -39,7 +39,7 @@ You can avoid showing trailing characters by passing a blank string as the secon

Input

```liquid -{% raw %} +{%- raw -%} {{ "Ground control to Major Tom." | truncatewords: 3, "" }} {% endraw %} ``` diff --git a/_filters/uniq.md b/_filters/uniq.md index c512da7d9..0f87b5ccb 100644 --- a/_filters/uniq.md +++ b/_filters/uniq.md @@ -7,7 +7,7 @@ Removes any duplicate items in an array.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %} {{ my_array | uniq | join: ", " }} diff --git a/_filters/upcase.md b/_filters/upcase.md index 627853723..d131b43c5 100644 --- a/_filters/upcase.md +++ b/_filters/upcase.md @@ -7,7 +7,7 @@ Makes each character in a string uppercase. It has no effect on strings which ar

Input

```liquid -{% raw %} +{%- raw -%} {{ "Parker Moore" | upcase }} {% endraw %} ``` @@ -19,7 +19,7 @@ Makes each character in a string uppercase. It has no effect on strings which ar

Input

```liquid -{% raw %} +{%- raw -%} {{ "APPLE" | upcase }} {% endraw %} ``` diff --git a/_filters/url_decode.md b/_filters/url_decode.md index 5ec572fe7..e5559c932 100644 --- a/_filters/url_decode.md +++ b/_filters/url_decode.md @@ -8,7 +8,7 @@ Decodes a string that has been encoded as a URL or by [`url_encode`]({{ "/filter

Input

```liquid -{% raw %} +{%- raw -%} {{ "%27Stop%21%27+said+Fred" | url_decode }} {% endraw %} ``` diff --git a/_filters/url_encode.md b/_filters/url_encode.md index b07af5b0e..74fe92935 100644 --- a/_filters/url_encode.md +++ b/_filters/url_encode.md @@ -7,7 +7,7 @@ Converts any URL-unsafe characters in a string into percent-encoded characters.

Input

```liquid -{% raw %} +{%- raw -%} {{ "john@liquid.com" | url_encode }} {% endraw %} ``` @@ -21,7 +21,7 @@ Note that `url_encode` will turn a space into a `+` sign instead of a percent-en

Input

```liquid -{% raw %} +{%- raw -%} {{ "Tetsuro Takara" | url_encode }} {% endraw %} ``` diff --git a/_filters/where.md b/_filters/where.md index d28967edb..80d800426 100644 --- a/_filters/where.md +++ b/_filters/where.md @@ -10,7 +10,7 @@ In this example, assume you have a list of products and you want to show your ki

Input

```liquid -{% raw %} +{%- raw -%} All products: {% for product in products %} - {{ product.title }} @@ -42,7 +42,7 @@ Say instead you have a list of products and you only want to show those that are

Input

```liquid -{% raw %} +{%- raw -%} All products: {% for product in products %} - {{ product.title }} @@ -73,7 +73,7 @@ The `where` filter can also be used to find a single object in an array when com

Input

```liquid -{% raw %} +{%- raw -%} {% assign new_shirt = products | where: "type", "shirt" | first %} Featured product: {{ new_shirt.title }} diff --git a/_tags/control-flow.md b/_tags/control-flow.md index 6a6bfc3e3..457f560bd 100644 --- a/_tags/control-flow.md +++ b/_tags/control-flow.md @@ -12,7 +12,7 @@ Executes a block of code only if a certain condition is `true`.

Input

```liquid -{% raw %} +{%- raw -%} {% if product.title == "Awesome Shoes" %} These shoes are awesome! {% endif %} @@ -30,7 +30,7 @@ The opposite of `if` – executes a block of code only if a certain condition is

Input

```liquid -{% raw %} +{%- raw -%} {% unless product.title == "Awesome Shoes" %} These shoes are not awesome. {% endunless %} @@ -45,7 +45,7 @@ These shoes are not awesome. This would be the equivalent of doing the following: ```liquid -{% raw %} +{%- raw -%} {% if product.title != "Awesome Shoes" %} These shoes are not awesome. {% endif %} @@ -58,7 +58,7 @@ Adds more conditions within an `if` or `unless` block.

Input

```liquid -{% raw %} +{%- raw -%} {% if customer.name == "kevin" %} Hey Kevin! @@ -83,7 +83,7 @@ An optional `else` statement at the end of the case provides code to execute if

Input

```liquid -{% raw %} +{%- raw -%} {% assign handle = "cake" %} {% case handle %} {% when "cake" %} diff --git a/_tags/iteration.md b/_tags/iteration.md index ea069598f..2d68031eb 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -11,7 +11,7 @@ Repeatedly executes a block of code. For a full list of attributes available wit

Input

```liquid -{% raw %} +{%- raw -%} {% for product in collection.products %} {{ product.title }} {% endfor %} @@ -29,7 +29,7 @@ Specifies a fallback case for a `for` loop which will run if the loop has zero l

Input

```liquid -{% raw %} +{%- raw -%} {% for product in collection.products %} {{ product.title }} {% else %} @@ -49,7 +49,7 @@ Causes the loop to stop iterating when it encounters the `break` tag.

Input

```liquid -{% raw %} +{%- raw -%} {% for i in (1..5) %} {% if i == 4 %} {% break %} @@ -71,7 +71,7 @@ Causes the loop to skip the current iteration when it encounters the `continue`

Input

```liquid -{% raw %} +{%- raw -%} {% for i in (1..5) %} {% if i == 4 %} {% continue %} @@ -95,7 +95,7 @@ Limits the loop to the specified number of iterations.

Input

```liquid -{% raw %} +{%- raw -%} {% for item in array limit:2 %} {{ item }} @@ -114,7 +114,7 @@ Begins the loop at the specified index.

Input

```liquid -{% raw %} +{%- raw -%} {% for item in array offset:2 %} {{ item }} @@ -131,7 +131,7 @@ To start a loop from where the last loop using the same iterator left off, pass

Input

```liquid -{% raw %} +{%- raw -%} {% for item in array limit: 3 %} {{ item }} @@ -154,7 +154,7 @@ Defines a range of numbers to loop through. The range can be defined by both lit

Input

```liquid -{% raw %} +{%- raw -%} {% for i in (3..5) %} {{ i }} {% endfor %} @@ -179,7 +179,7 @@ Reverses the order of the loop. Note that this flag's spelling is different from

Input

```liquid -{% raw %} +{%- raw -%} {% for item in array reversed %} {{ item }} @@ -200,7 +200,7 @@ Loops through a group of strings and prints them in the order that they were pas

Input

```liquid -{% raw %} +{%- raw -%} {% cycle "one", "two", "three" %} {% cycle "one", "two", "three" %} {% cycle "one", "two", "three" %} @@ -227,7 +227,7 @@ Uses for `cycle` include:

Input

```liquid -{% raw %} +{%- raw -%} {% cycle "first": "one", "two", "three" %} {% cycle "second": "one", "two", "three" %} {% cycle "second": "one", "two", "three" %} @@ -249,7 +249,7 @@ Generates an HTML table. Must be wrapped in opening `` and closing `Input

```liquid -{% raw %} +{%- raw -%}
{% tablerow product in collection.products %} {{ product.title }} @@ -292,7 +292,7 @@ Defines how many columns the tables should have.

Input

```liquid -{% raw %} +{%- raw -%} {% tablerow product in collection.products cols:2 %} {{ product.title }} {% endtablerow %} @@ -334,7 +334,7 @@ Defines how many columns the tables should have. Exits the `tablerow` loop after a specific index. ```liquid -{% raw %} +{%- raw -%} {% tablerow product in collection.products cols:2 limit:3 %} {{ product.title }} {% endtablerow %} @@ -346,7 +346,7 @@ Exits the `tablerow` loop after a specific index. Starts the `tablerow` loop after a specific index. ```liquid -{% raw %} +{%- raw -%} {% tablerow product in collection.products cols:2 offset:3 %} {{ product.title }} {% endtablerow %} @@ -358,7 +358,7 @@ Starts the `tablerow` loop after a specific index. Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers. ```liquid -{% raw %} +{%- raw -%} {% assign num = 4 %} diff --git a/_tags/template.md b/_tags/template.md index 547411200..21420354a 100644 --- a/_tags/template.md +++ b/_tags/template.md @@ -14,7 +14,7 @@ Allows you to leave un-rendered code inside a Liquid template. Any text within t

Input

```liquid -{% raw %} +{%- raw -%} {% assign verb = "turned" %} {% comment %} {% assign verb = "converted" %} @@ -57,7 +57,7 @@ In Handlebars, {{ this }} will be HTML-escaped, but {{{ that }}} will not. Encloses multiple tags within one set of delimiters, to allow writing Liquid logic more concisely. ```liquid -{% raw %} +{%- raw -%} {% liquid case section.blocks.size when 1 @@ -80,7 +80,7 @@ Outputs an expression in the rendered HTML. This is identical to wrapping an exp

Input

```liquid -{% raw %} +{%- raw -%} {% liquid for product in collection.products echo product.title | capitalize @@ -98,7 +98,7 @@ Hat Shirt Pants Insert the rendered content of another template within the current template. ```liquid -{% raw %} +{%- raw -%} {% render "template-name" %} {% endraw %} ``` @@ -112,7 +112,7 @@ The code within the rendered template does **not** automatically have access to Variables assigned using [variable tags]({{ "/tags/variable/" | prepend: site.baseurl }}) can be passed to a template by listing them as parameters on the `render` tag. ```liquid -{% raw %} +{%- raw -%} {% assign my_variable = "apples" %} {% render "name", my_variable: my_variable, my_other_variable: "oranges" %} {% endraw %} @@ -121,7 +121,7 @@ Variables assigned using [variable tags]({{ "/tags/variable/" | prepend: site.ba One or more objects can be passed to a template. ```liquid -{% raw %} +{%- raw -%} {% assign featured_product = all_products["product_handle"] %} {% render "product", product: featured_product %} {% endraw %} @@ -132,7 +132,7 @@ One or more objects can be passed to a template. A single object can be passed to a template by using the `with` and optional `as` parameters. ```liquid -{% raw %} +{%- raw -%} {% assign featured_product = all_products["product_handle"] %} {% render "product" with featured_product as product %} {% endraw %} @@ -145,7 +145,7 @@ In the example above, the `product` variable in the rendered template will hold A template can be rendered once for each value of an enumerable object by using the `for` and optional `as` parameters. ```liquid -{% raw %} +{%- raw -%} {% assign variants = product.variants %} {% render "product_variant" for variants as variant %} {% endraw %} @@ -162,7 +162,7 @@ _The `include` tag is deprecated; please use [`render`](#render) instead._ Insert the rendered content of another template within the current template. ```liquid -{% raw %} +{%- raw -%} {% include "template-name" %} {% endraw %} ``` diff --git a/_tags/variable.md b/_tags/variable.md index 3c8f4ca39..cac9be4f8 100644 --- a/_tags/variable.md +++ b/_tags/variable.md @@ -11,7 +11,7 @@ Creates a new named variable.

Input

```liquid -{% raw %} +{%- raw -%} {% assign my_variable = false %} {% if my_variable != true %} This statement is valid. @@ -28,7 +28,7 @@ Wrap a value in quotations `"` to save it as a string variable.

Input

```liquid -{% raw %} +{%- raw -%} {% assign foo = "bar" %} {{ foo }} {% endraw %} @@ -46,7 +46,7 @@ Captures the string inside of the opening and closing tags and assigns it to a v

Input

```liquid -{% raw %} +{%- raw -%} {% capture my_variable %}I am being captured.{% endcapture %} {{ my_variable }} {% endraw %} @@ -61,7 +61,7 @@ Using `capture`, you can create complex strings using other variables created wi

Input

```liquid -{% raw %} +{%- raw -%} {% assign favorite_food = "pizza" %} {% assign age = 35 %} @@ -84,7 +84,7 @@ Creates and outputs a new number variable with initial value `0`. On subsequent

Input

```liquid -{% raw %} +{%- raw -%} {% increment my_counter %} {% increment my_counter %} {% increment my_counter %} @@ -104,7 +104,7 @@ In the example below, a variable named "var" is created using `assign`. The `inc

Input

```liquid -{% raw %} +{%- raw -%} {% assign var = 10 %} {% increment var %} {% increment var %} @@ -128,7 +128,7 @@ Creates and outputs a new number variable with initial value `-1`. On subsequent

Input

```liquid -{% raw %} +{%- raw -%} {% decrement variable %} {% decrement variable %} {% decrement variable %}