diff --git a/Gemfile.lock b/Gemfile.lock index e5ad786..958dc1d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,22 +21,22 @@ GEM multipart-post (>= 1.2, < 3) ffi (1.9.10) gemoji (2.1.0) - github-pages (64) + github-pages (68) RedCloth (= 4.2.9) github-pages-health-check (= 1.1.0) jekyll (= 3.0.3) jekyll-coffeescript (= 1.0.1) jekyll-feed (= 0.4.0) jekyll-gist (= 1.4.0) - jekyll-github-metadata (= 1.9.0) - jekyll-mentions (= 1.0.1) + jekyll-github-metadata (= 1.10.0) + jekyll-mentions (= 1.1.2) jekyll-paginate (= 1.1.0) jekyll-redirect-from (= 0.10.0) jekyll-sass-converter (= 1.3.0) - jekyll-seo-tag (= 1.3.2) + jekyll-seo-tag (= 1.3.3) jekyll-sitemap (= 0.10.0) jekyll-textile-converter (= 0.1.0) - jemoji (= 0.5.1) + jemoji (= 0.6.2) kramdown (= 1.10.0) liquid (= 3.0.6) mercenary (~> 0.3) @@ -68,9 +68,9 @@ GEM jekyll-feed (0.4.0) jekyll-gist (1.4.0) octokit (~> 4.2) - jekyll-github-metadata (1.9.0) + jekyll-github-metadata (1.10.0) octokit (~> 4.0) - jekyll-mentions (1.0.1) + jekyll-mentions (1.1.2) html-pipeline (~> 2.3) jekyll (~> 3.0) jekyll-paginate (1.1.0) @@ -78,17 +78,17 @@ GEM jekyll (>= 2.0) jekyll-sass-converter (1.3.0) sass (~> 3.2) - jekyll-seo-tag (1.3.2) + jekyll-seo-tag (1.3.3) jekyll (~> 3.0) jekyll-sitemap (0.10.0) jekyll-textile-converter (0.1.0) RedCloth (~> 4.0) jekyll-watch (1.3.1) listen (~> 3.0) - jemoji (0.5.1) + jemoji (0.6.2) gemoji (~> 2.0) html-pipeline (~> 2.2) - jekyll (>= 2.0) + jekyll (>= 3.0) json (1.8.3) kramdown (1.10.0) liquid (3.0.6) @@ -112,7 +112,7 @@ GEM redcarpet (3.3.3) rouge (1.10.1) safe_yaml (1.0.4) - sass (3.4.21) + sass (3.4.22) sawyer (0.7.0) addressable (>= 2.3.5, < 2.5) faraday (~> 0.8, < 0.10) diff --git a/_config.yml b/_config.yml index 993b70e..3aa3cb8 100644 --- a/_config.yml +++ b/_config.yml @@ -1,14 +1,11 @@ title: Liquid Templating Engine description: "Liquid is a template language and accompanying rendering engine. It is built for security, so is perfect for rendering custom templates from your users." + repository: https://github.com/Shopify/liquid # Build settings baseurl: /liquid # the subpath of your site, e.g. /blog/ -url: https://shopify.github.io # the base hostname & protocol for your site -markdown: redcarpet -redcarpet: - extensions: ["with_toc_data", "tables", "disable_indented_code_blocks", "no_intra_emphasis"] -highlighter: pygments +url: http://liquidmarkup.org # the base hostname & protocol for your site permalink: pretty exclude: - README.md diff --git a/_sass/modules/_content-area.scss b/_sass/modules/_content-area.scss index 11ed206..dbee405 100644 --- a/_sass/modules/_content-area.scss +++ b/_sass/modules/_content-area.scss @@ -3,29 +3,20 @@ } .highlight { - - pre { - border-top: none; - border-radius: 0 0 3px 3px; - } - - &:before { - content: "Example"; - display: block; - padding: 8px 12px; - color: $color-slate; - background: #fff; - border: 1px solid $color-blue-2; - border-radius: 3px 3px 0 0; - font-size: 16px; - font-weight: bold; - } - - // Label every second code block with "Output" - & + .highlight:nth-of-type(2n) { - &:before { - content: "Output"; - } - } - + background: lighten($color-blue-1, 1); +} + +.code-label { + padding: 4px 12px; + margin-bottom: 0; + font-size: 15px; + background: darken($color-blue-1, 5); + border: 1px solid $color-blue-2; + border-bottom: none; + border-radius: 3px 3px 0 0; +} + +.code-label + .highlighter-rouge .highlight { + border-top: none; + border-radius: 0 0 3px 3px; } diff --git a/_sass/vendors/_syntax-highlighting.scss b/_sass/vendors/_syntax-highlighting.scss index e36627d..4158102 100644 --- a/_sass/vendors/_syntax-highlighting.scss +++ b/_sass/vendors/_syntax-highlighting.scss @@ -2,7 +2,7 @@ * Syntax highlighting styles */ .highlight { - background: #fff; + // background: #fff; @extend %vertical-rhythm; .c { color: #998; font-style: italic } // Comment diff --git a/basics/introduction.md b/basics/introduction.md index 2dd1e81..b857665 100644 --- a/basics/introduction.md +++ b/basics/introduction.md @@ -9,12 +9,14 @@ Liquid code can be categorized into [**objects**](#objects), [**tags**](#tags), **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 %}`. +

Input

```liquid {% raw %} {{ page.title }} {% endraw %} ``` +

Output

```text Introduction ``` @@ -27,15 +29,16 @@ In this case, Liquid is rendering the content of an object called `page.title`, 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. +

Input

```liquid {% raw %} {% if user %} Hello {{ user.name }}! {% endif %} - {% endraw %} ``` +

Output

```text Hello Adam! ``` @@ -53,12 +56,14 @@ You can read more about each type of tag in their respective sections. **Filters** change the output of a Liquid object. They are using within an output and are separated by a `|`. +

Input

```liquid {% raw %} {{ "/my/fancy/url" | append: ".html" }} {% endraw %} ``` +

Output

```text {{ "/my/fancy/url" | append: ".html" }} ``` diff --git a/basics/truthy-and-falsy.md b/basics/truthy-and-falsy.md index 703a0ae..f7d1e56 100644 --- a/basics/truthy-and-falsy.md +++ b/basics/truthy-and-falsy.md @@ -26,6 +26,7 @@ In the example below, the string "Tobi" is not a boolean, but it is truthy in a [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: +

Input

```liquid {% raw %} {% if settings.fp_heading %} @@ -34,6 +35,7 @@ In the example below, the string "Tobi" is not a boolean, but it is truthy in a {% endraw %} ``` +

Output

```html

``` diff --git a/basics/types.md b/basics/types.md index 37b6f24..ee1b23c 100644 --- a/basics/types.md +++ b/basics/types.md @@ -62,12 +62,14 @@ In the following example, if the user does not exist (that is, `user` returns `n Tags or outputs that return `nil` will not print anything to the page. +

Input

```liquid {% raw %} The current user is {{ user.name }} {% endraw %} ``` +

Output

```text The current user is ``` @@ -80,6 +82,7 @@ Arrays hold lists of variables of any type. To access all the items in an array, you can loop through each item in the array using an [iteration tag]({{ "/tags/iteration" | prepend: site.baseurl }}). +

Input

```liquid {% raw %} @@ -89,6 +92,7 @@ To access all the items in an array, you can loop through each item in the array {% endraw %} ``` +

Output

```text {% raw %} Tobi Laura Tetsuro Adam @@ -99,6 +103,7 @@ Tobi Laura Tetsuro Adam You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero. +

Input

```liquid {% raw %} @@ -108,6 +113,7 @@ You can use square bracket `[` `]` notation to access a specific item in an arra {% endraw %} ``` +

Output

```text Tobi Laura diff --git a/filters/append.md b/filters/append.md index 1b6202f..abd414f 100644 --- a/filters/append.md +++ b/filters/append.md @@ -4,18 +4,21 @@ title: append Concatenates two strings and returns the concatenated value. +

Input

```liquid {% raw %} {{ "/my/fancy/url" | append: ".html" }} {% endraw %} ``` +

Output

```text {{ "/my/fancy/url" | append: ".html" }} ``` `append` can also be used with variables: +

Input

```liquid {% raw %} {% assign filename = "/index.html" %} @@ -23,6 +26,7 @@ Concatenates two strings and returns the concatenated value. {% endraw %} ``` +

Output

```text {% assign filename = "/index.html" %} {{ "website.com" | append: filename }} diff --git a/filters/capitalize.md b/filters/capitalize.md index ef9ecbe..1ff06d2 100644 --- a/filters/capitalize.md +++ b/filters/capitalize.md @@ -4,24 +4,28 @@ title: capitalize Makes the first character of a string capitalized. +

Input

```liquid {% raw %} {{ "title" | capitalize }} {% endraw %} ``` +

Output

```text Title ``` `capitalize` only capitalizes the first character of the string, so later words are not affected: - ```liquid +

Input

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

Output

```text My great title ``` diff --git a/filters/ceil.md b/filters/ceil.md index f297651..b9cb03e 100644 --- a/filters/ceil.md +++ b/filters/ceil.md @@ -4,44 +4,52 @@ title: ceil Rounds the input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied. +

Input

```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 {{ 183.357 | ceil }} ``` Here the input value is a string: +

Input

```liquid {% raw %} {{ "3.5" | ceil }} {% endraw %} ``` +

Output

```text {{ "3.5" | ceil }} ``` diff --git a/filters/date.md b/filters/date.md index 4048def..0b47e9c 100644 --- a/filters/date.md +++ b/filters/date.md @@ -4,34 +4,40 @@ title: date Converts a timestamp into another date format. The format for this syntax is the same as [`strftime`](//strftime.net). +

Input

```liquid {% raw %} {{ article.published_at | date: "%a, %b %d, %y" }} {% endraw %} ``` +

Output

```text Fri, Jul 17, 15 ``` +

Input

```liquid {% raw %} {{ article.published_at | date: "%Y" }} {% endraw %} ``` +

Output

```text 2015 ``` `date` works on strings if they contain well-formatted dates: +

Input

```liquid {% raw %} {{ "March 14, 2016" | date: "%b %d, %y" }} {% endraw %} ``` +

Output

```text {{ "March 14, 2016" | date: "%b %d, %y" }} ``` diff --git a/filters/default.md b/filters/default.md index 28020e9..96249a1 100644 --- a/filters/default.md +++ b/filters/default.md @@ -6,18 +6,21 @@ Allows you to specify a fallback in case a value doesn't exist. `default` will s In this example, `product_price` is not defined, so the default value is used. +

Input

```liquid {% raw %} {{ product_price | default: 2.99 }} {% endraw %} ``` +

Output

```text 2.99 ``` In this example, `product_price` is defined, so the default value is not used. +

Input

```liquid {% raw %} {% assign product_price = 4.99 %} @@ -25,12 +28,14 @@ In this example, `product_price` is defined, so the default value is not used. {% endraw %} ``` +

Output

```text 4.99 ``` In this example, `product_price` is empty, so the default value is used. +

Input

```liquid {% raw %} {% assign product_price = "" %} @@ -38,7 +43,7 @@ In this example, `product_price` is empty, so the default value is used. {% endraw %} ``` +

Output

```text 2.99 ``` - diff --git a/filters/divided_by.md b/filters/divided_by.md index b17e4bd..caeef2f 100644 --- a/filters/divided_by.md +++ b/filters/divided_by.md @@ -6,32 +6,38 @@ Divides a number by the specified number. The result is rounded down to the nearest integer (that is, the [floor]({{ "/filters/floor" | prepend: site.baseurl }})). +

Input

```liquid {% raw %} {{ 4 | divided_by: 2 }} {% endraw %} ``` +

Output

```text {{ 4 | divided_by: 2 }} ``` +

Input

```liquid {% raw %} {{ 16 | divided_by: 4 }} {% endraw %} ``` +

Output

```text {{ 16 | divided_by: 4 }} ``` +

Input

```liquid {% raw %} {{ 5 | divided_by: 3 }} {% endraw %} ``` +

Output

```text {{ 5 | divided_by: 3 }} ``` diff --git a/filters/downcase.md b/filters/downcase.md index f86c952..eaec276 100644 --- a/filters/downcase.md +++ b/filters/downcase.md @@ -4,22 +4,26 @@ title: downcase Makes each character in a string lowercase. It has no effect on strings which are already all lowercase. +

Input

```liquid {% raw %} {{ "Parker Moore" | downcase }} {% endraw %} ``` +

Output

```text {{ "Parker Moore" | downcase }} ``` +

Input

```liquid {% raw %} {{ "apple" | downcase }} {% endraw %} ``` +

Output

```text {{ "apple" | downcase }} ``` diff --git a/filters/escape.md b/filters/escape.md index 508f808..777fd7a 100644 --- a/filters/escape.md +++ b/filters/escape.md @@ -4,22 +4,26 @@ title: escape Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn't change strings that don't have anything to escape. +

Input

```liquid {% raw %} {{ "Have you read 'James & the Giant Peach'?" | escape }} {% endraw %} ``` +

Output

```text {{ "Have you read 'James & the Giant Peach'?" | escape }} ``` +

Input

```liquid {% raw %} {{ "Tetsuro Takara" | escape }} {% endraw %} ``` +

Output

```text {{ "Tetsuro Takara" | escape }} ``` diff --git a/filters/escape_once.md b/filters/escape_once.md index e8160a9..3edcae3 100644 --- a/filters/escape_once.md +++ b/filters/escape_once.md @@ -4,22 +4,26 @@ title: escape_once Escapes a string without changing existing escaped entities. It doesn't change strings that don't have anything to escape. +

Input

```liquid {% raw %} {{ "1 < 2 & 3" | escape_once }} {% endraw %} ``` +

Output

```text {{ "1 < 2 & 3" | escape_once }} ``` +

Input

```liquid {% raw %} {{ "1 < 2 & 3" | escape_once }} {% endraw %} ``` +

Output

```text {{ "1 < 2 & 3" | escape_once }} ``` diff --git a/filters/first.md b/filters/first.md index 8513a60..f87479b 100644 --- a/filters/first.md +++ b/filters/first.md @@ -4,6 +4,7 @@ title: first Returns the first item of an array. +

Input

```liquid {% raw %} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} @@ -12,12 +13,14 @@ Returns the first item of an array. {% endraw %} ``` +

Output

```text {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} {{ my_array.first }} ``` +

Input

```liquid {% raw %} {% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} @@ -26,6 +29,7 @@ Returns the first item of an array. {% endraw %} ``` +

Output

```text {% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} diff --git a/filters/floor.md b/filters/floor.md index 306ae15..dccc10e 100644 --- a/filters/floor.md +++ b/filters/floor.md @@ -4,44 +4,52 @@ title: floor Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied. +

Input

```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 {{ 183.357 | floor }} ``` Here the input value is a string: +

Input

```liquid {% raw %} {{ "3.5" | floor }} {% endraw %} ``` +

Output

```text {{ "3.5" | floor }} ``` diff --git a/filters/join.md b/filters/join.md index dfff763..c0dee8d 100644 --- a/filters/join.md +++ b/filters/join.md @@ -4,6 +4,7 @@ title: join Combines the items in an array into a single string using the argument as a separator. +

Input

```liquid {% raw %} {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} @@ -12,6 +13,7 @@ Combines the items in an array into a single string using the argument as a sepa {% endraw %} ``` +

Output

```text {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} diff --git a/filters/last.md b/filters/last.md index 5e4454e..5f3c680 100644 --- a/filters/last.md +++ b/filters/last.md @@ -4,6 +4,7 @@ title: last Returns the last item of an array. +

Input

```liquid {% raw %} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} @@ -12,12 +13,14 @@ Returns the last item of an array. {% endraw %} ``` +

Output

```text {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} {{ my_array.last }} ``` +

Input

```liquid {% raw %} {% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} @@ -26,6 +29,7 @@ Returns the last item of an array. {% endraw %} ``` +

Output

```text {% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %} diff --git a/filters/lstrip.md b/filters/lstrip.md index 72db9ab..b143bb3 100644 --- a/filters/lstrip.md +++ b/filters/lstrip.md @@ -4,12 +4,14 @@ title: lstrip Removes all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words. +

Input

```liquid {% raw %} {{ " So much room for activities! " | lstrip }} {% endraw %} ``` +

Output

```text {{ " So much room for activities! " | lstrip }} ``` diff --git a/filters/map.md b/filters/map.md index 37b7b9a..61fddb9 100644 --- a/filters/map.md +++ b/filters/map.md @@ -6,6 +6,7 @@ Creates an array of values by extracting the values of a named property from ano In this example, assume the object `site.pages` contains all the metadata for a website. Using `assign` with the `map` filter creates a variable that contains only the values of the `category` properties of everything in the `site.pages` object. +

Input

```liquid {% raw %} {% assign all_categories = site.pages | map: "category" %} @@ -16,6 +17,7 @@ In this example, assume the object `site.pages` contains all the metadata for a {% endraw %} ``` +

Output

```text business celebrities diff --git a/filters/minus.md b/filters/minus.md index 0ccc036..f9d4474 100644 --- a/filters/minus.md +++ b/filters/minus.md @@ -4,32 +4,38 @@ title: minus Subtracts a number from another number. +

Input

```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 {{ 183.357 | minus: 12 }} ``` diff --git a/filters/modulo.md b/filters/modulo.md index 6a57cd3..bb31570 100644 --- a/filters/modulo.md +++ b/filters/modulo.md @@ -4,32 +4,38 @@ title: modulo Returns the remainder of a division operation. +

Input

```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 {{ 183.357 | modulo: 12 }} ``` diff --git a/filters/newline_to_br.md b/filters/newline_to_br.md index c5aabbc..a936e40 100644 --- a/filters/newline_to_br.md +++ b/filters/newline_to_br.md @@ -4,6 +4,7 @@ title: newline_to_br Replaces every newline (`\n`) with an HTML line break (`
`). +

Input

```liquid {% raw %} {% capture string_with_newlines %} @@ -15,6 +16,7 @@ there {% endraw %} ``` +

Output

```html {% capture string_with_newlines %} Hello diff --git a/filters/plus.md b/filters/plus.md index 617a855..52e97ac 100644 --- a/filters/plus.md +++ b/filters/plus.md @@ -4,32 +4,38 @@ title: plus Adds a number to another number. +

Input

```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 {{ 183.357 | plus: 12 }} ``` diff --git a/filters/prepend.md b/filters/prepend.md index 2702edb..98464b0 100644 --- a/filters/prepend.md +++ b/filters/prepend.md @@ -4,18 +4,21 @@ title: prepend Adds the specified string to the beginning of another string. +

Input

```liquid {% raw %} {{ "apples, oranges, and bananas" | prepend: "Some fruit: " }} {% endraw %} ``` +

Output

```text {{ "apples, oranges, and bananas" | prepend: "Some fruit: " }} ``` You can also `prepend` variables: +

Input

```liquid {% raw %} {% assign url = "liquidmarkup.com" %} @@ -24,6 +27,7 @@ You can also `prepend` variables: {% endraw %} ``` +

Output

```text {% assign url = "liquidmarkup.com" %} diff --git a/filters/remove.md b/filters/remove.md index 6e9f695..6d517e8 100644 --- a/filters/remove.md +++ b/filters/remove.md @@ -4,12 +4,14 @@ title: remove Removes every occurrence of the specified substring from a string. +

Input

```liquid {% raw %} {{ "I strained to see the train through the rain" | remove: "rain" }} {% endraw %} ``` +

Output

```text {{ "I strained to see the train through the rain" | remove: "rain" }} ``` diff --git a/filters/remove_first.md b/filters/remove_first.md index 3b7157d..5f18ff7 100644 --- a/filters/remove_first.md +++ b/filters/remove_first.md @@ -4,12 +4,14 @@ title: remove_first Removes only the first occurrence of the specified substring from a string. +

Input

```liquid {% raw %} {{ "I strained to see the train through the rain" | remove_first: "rain" }} {% endraw %} ``` +

Output

```text {{ "I strained to see the train through the rain" | remove_first: "rain" }} ``` diff --git a/filters/replace.md b/filters/replace.md index 62a14f2..823c091 100644 --- a/filters/replace.md +++ b/filters/replace.md @@ -4,12 +4,14 @@ title: replace Replaces every occurrence of an argument in a string with the second argument. +

Input

```liquid {% raw %} {{ "Take my protein pills and put my helmet on" | replace: "my", "your" }} {% endraw %} ``` +

Output

```text {{ "Take my protein pills and put my helmet on" | replace: "my", "your" }} ``` diff --git a/filters/replace_first.md b/filters/replace_first.md index b8056cc..df43519 100644 --- a/filters/replace_first.md +++ b/filters/replace_first.md @@ -4,6 +4,7 @@ title: replace_first Replaces only the first occurrence of the first argument in a string with the second argument. +

Input

```liquid {% raw %} {% assign my_string = "Take my protein pills and put my helmet on" %} @@ -11,6 +12,7 @@ Replaces only the first occurrence of the first argument in a string with the se {% endraw %} ``` +

Output

```text {% assign my_string = "Take my protein pills and put my helmet on" %} {{ my_string | replace_first: "my", "your" }} diff --git a/filters/reverse.md b/filters/reverse.md index 15432f9..c4eb594 100644 --- a/filters/reverse.md +++ b/filters/reverse.md @@ -4,6 +4,7 @@ title: reverse Reverses the order of the items in an array. `reverse` cannot reverse a string. +

Input

```liquid {% raw %} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} @@ -12,6 +13,7 @@ Reverses the order of the items in an array. `reverse` cannot reverse a string. {% endraw %} ``` +

Output

```text {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} @@ -20,12 +22,14 @@ Reverses the order of the items in an array. `reverse` cannot reverse a string. `reverse` cannot be used directly on a string, but you can split a string into an array, reverse the array, and rejoin it by chaining together filters: +

Input

```liquid {% raw %} {{ "Ground control to Major Tom." | split: "" | reverse | join: "" }} {% endraw %} ``` +

Output

```text {{ "Ground control to Major Tom." | split: "" | reverse | join: "" }} ``` diff --git a/filters/round.md b/filters/round.md index 548386f..88913eb 100644 --- a/filters/round.md +++ b/filters/round.md @@ -4,32 +4,38 @@ title: round Rounds an input number to the nearest integer or, if a number is specified as an argument, to that number of decimal places. +

Input

```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 {{ 183.357 | round: 2 }} ``` diff --git a/filters/rstrip.md b/filters/rstrip.md index 3aee7da..e2d7284 100644 --- a/filters/rstrip.md +++ b/filters/rstrip.md @@ -4,12 +4,14 @@ title: rstrip Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. +

Input

```liquid {% raw %} {{ " So much room for activities! " | rstrip }} {% endraw %} ``` +

Output

```text {{ " So much room for activities! " | rstrip }} ``` diff --git a/filters/size.md b/filters/size.md index 0242459..fe2c4c4 100644 --- a/filters/size.md +++ b/filters/size.md @@ -4,16 +4,19 @@ title: size Returns the number of characters in a string or the number of items in an array. `size` can also be used with dot notation (for example, `{% raw %}{{ my_string.size }}{% endraw %}`). This allows you to use `size` inside tags such as conditionals. +

Input

```liquid {% raw %} {{ "Ground control to Major Tom." | size }} {% endraw %} ``` +

Output

```text {{ "Ground control to Major Tom." | size }} ``` +

Input

```liquid {% raw %} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} @@ -22,6 +25,7 @@ Returns the number of characters in a string or the number of items in an array. {% endraw %} ``` +

Output

```text {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} diff --git a/filters/slice.md b/filters/slice.md index 79aedad..9265595 100644 --- a/filters/slice.md +++ b/filters/slice.md @@ -6,44 +6,52 @@ Returns a substring of 1 character beginning at the index specified by the argum String indices are numbered starting from 0. +

Input

```liquid {% raw %} {{ "Liquid" | slice: 0 }} {% endraw %} ``` +

Output

```text {{ "Liquid" | slice: 0 }} ``` +

Input

```liquid {% raw %} {{ "Liquid" | slice: 2 }} {% endraw %} ``` +

Output

```text {{ "Liquid" | slice: 2 }} ``` +

Input

```liquid {% raw %} {{ "Liquid" | slice: 2, 5 }} {% endraw %} ``` +

Output

```text {{ "Liquid" | slice: 2, 5 }} ``` If the first parameter is a negative number, the indices are counted from the end of the string: +

Input

```liquid {% raw %} {{ "Liquid" | slice: -3, 2 }} {% endraw %} ``` +

Output

```text {{ "Liquid" | slice: -3, 2 }} ``` diff --git a/filters/sort.md b/filters/sort.md index 4c3c599..9a34de9 100644 --- a/filters/sort.md +++ b/filters/sort.md @@ -4,6 +4,7 @@ title: sort Sorts items in an array by a property of an item in the array. The order of the sorted array is case-sensitive. +

Input

```liquid {% raw %} {% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %} @@ -12,6 +13,7 @@ Sorts items in an array by a property of an item in the array. The order of the {% endraw %} ``` +

Output

```text {% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %} diff --git a/filters/split.md b/filters/split.md index 740b6b4..b56218a 100644 --- a/filters/split.md +++ b/filters/split.md @@ -4,6 +4,7 @@ title: split Divides an input string into an array using the argument as a separator. `split` is commonly used to convert comma-separated items from a string to an array. +

Input

```liquid {% raw %} {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} @@ -14,6 +15,7 @@ Divides an input string into an array using the argument as a separator. `split` {% endraw %} ``` +

Output

```text {% assign beatles = "John, Paul, George, Ringo" | split: ", " %} diff --git a/filters/strip.md b/filters/strip.md index 588bbdf..97218d7 100644 --- a/filters/strip.md +++ b/filters/strip.md @@ -4,12 +4,14 @@ title: strip Removes all whitespace (tabs, spaces, and newlines) from both the left and right side of a string. It does not affect spaces between words. +

Input

```liquid {% raw %} {{ " So much room for activities! " | strip }} {% endraw %} ``` +

Output

```text {{ " So much room for activities! " | strip }} ``` diff --git a/filters/strip_html.md b/filters/strip_html.md index b41eafd..3c9a3d1 100644 --- a/filters/strip_html.md +++ b/filters/strip_html.md @@ -4,12 +4,14 @@ title: strip_html Removes any HTML tags from a string. +

Input

```liquid {% raw %} {{ "Have you read Ulysses?" | strip_html }} {% endraw %} ``` +

Output

```text {{ "Have you read Ulysses?" | strip_html }} ``` diff --git a/filters/strip_newlines.md b/filters/strip_newlines.md index 0a0d48d..675ff40 100644 --- a/filters/strip_newlines.md +++ b/filters/strip_newlines.md @@ -4,6 +4,7 @@ title: strip_newlines Removes any newline characters (line breaks) from a string. +

Input

```liquid {% raw %} {% capture string_with_newlines %} @@ -15,6 +16,7 @@ there {% endraw %} ``` +

Output

```html {% capture string_with_newlines %} Hello @@ -23,4 +25,3 @@ there {{ string_with_newlines | strip_newlines }} ``` - diff --git a/filters/times.md b/filters/times.md index 694959f..76e71c6 100644 --- a/filters/times.md +++ b/filters/times.md @@ -4,32 +4,38 @@ title: times Multiplies a number by another number. +

Input

```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 {{ 183.357 | times: 12 }} ``` diff --git a/filters/truncate.md b/filters/truncate.md index 45f018d..e2b4182 100644 --- a/filters/truncate.md +++ b/filters/truncate.md @@ -4,12 +4,14 @@ title: truncate `truncate` shortens a string down to the number of characters passed as a parameter. If the number of characters specified is less than the length of the string, an ellipsis (...) is appended to the string and is included in the character count. +

Input

```liquid {% raw %} {{ "Ground control to Major Tom." | truncate: 20 }} {% endraw %} ``` +

Output

```text {{ "Ground control to Major Tom." | truncate: 20 }} ``` diff --git a/filters/truncatewords.md b/filters/truncatewords.md index c9ee849..6ac5ad0 100644 --- a/filters/truncatewords.md +++ b/filters/truncatewords.md @@ -4,12 +4,14 @@ title: truncatewords Shortens a string down to the number of words passed as the argument. If the specified number of words is less than the number of words in the string, an ellipsis (...) is appended to the string. +

Input

```liquid {% raw %} {{ "Ground control to Major Tom." | truncatewords: 3 }} {% endraw %} ``` +

Output

```text {{ "Ground control to Major Tom." | truncatewords: 3 }} ``` diff --git a/filters/uniq.md b/filters/uniq.md index 7ff73b9..4846437 100644 --- a/filters/uniq.md +++ b/filters/uniq.md @@ -4,6 +4,7 @@ title: uniq Removes any duplicate elements in an array. +

Input

```liquid {% raw %} {% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %} @@ -12,6 +13,7 @@ Removes any duplicate elements in an array. {% endraw %} ``` +

Output

```text {% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %} diff --git a/filters/upcase.md b/filters/upcase.md index 2aa7f0d..105d3d1 100644 --- a/filters/upcase.md +++ b/filters/upcase.md @@ -4,22 +4,26 @@ title: upcase Makes each character in a string uppercase. It has no effect on strings which are already all uppercase. +

Input

```liquid {% raw %} {{ "Parker Moore" | upcase }} {% endraw %} ``` +

Output

```text {{ "Parker Moore" | upcase }} ``` +

Input

```liquid {% raw %} {{ "APPLE" | upcase }} {% endraw %} ``` +

Output

```text {{ "APPLE" | upcase }} ``` diff --git a/filters/url_encode.md b/filters/url_encode.md index 68b10d1..f0f5add 100644 --- a/filters/url_encode.md +++ b/filters/url_encode.md @@ -4,22 +4,26 @@ title: url_encode Converts any URL-unsafe characters in a string into percent-encoded characters. +

Input

```liquid {% raw %} {{ "john@liquid.com" | url_encode }} {% endraw %} ``` +

Output

```text {{ "john@liquid.com" | url_encode }} ``` +

Input

```liquid {% raw %} {{ "Tetsuro Takara" | url_encode }} {% endraw %} ``` +

Output

```text {{ "Tetsuro Takara" | url_encode }} ``` diff --git a/tags/control-flow.md b/tags/control-flow.md index 976e663..bae7080 100644 --- a/tags/control-flow.md +++ b/tags/control-flow.md @@ -8,6 +8,7 @@ Control flow tags can change the information Liquid shows using programming logi Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` compares its values. +

Input

```liquid {% raw %} {% assign handle = 'cake' %} @@ -22,6 +23,7 @@ Creates a switch statement to compare a variable with different values. `case` i {% endraw %} ``` +

Output

```text This is a cake ``` @@ -30,6 +32,7 @@ This is a cake Executes a block of code only if a certain condition is `true`. +

Input

```liquid {% raw %} {% if product.title == 'Awesome Shoes' %} @@ -38,6 +41,7 @@ Executes a block of code only if a certain condition is `true`. {% endraw %} ``` +

Output

```text These shoes are awesome! ``` @@ -46,6 +50,7 @@ These shoes are awesome! The opposite of `if` – executes a block of code only if a certain condition is **not** met. +

Input

```liquid {% raw %} {% unless product.title == 'Awesome Shoes' %} @@ -54,6 +59,7 @@ The opposite of `if` – executes a block of code only if a certain condition is {% endraw %} ``` +

Output

```text These shoes are not awesome. ``` @@ -72,6 +78,7 @@ This would be the equivalent of doing the following: Adds more conditions within an `if` or `unless` block. +

Input

```liquid {% raw %} @@ -85,6 +92,7 @@ Adds more conditions within an `if` or `unless` block. {% endraw %} ``` +

Output

```text Hey Anonymous! ``` diff --git a/tags/iteration.md b/tags/iteration.md index fbc7902..65bf971 100644 --- a/tags/iteration.md +++ b/tags/iteration.md @@ -8,6 +8,7 @@ Iteration tags run blocks of code repeatedly. Repeatedly executes a block of code. For a full list of attributes available within a `for` loop, see [forloop (object)](https://docs.shopify.com/themes/liquid/objects/for-loops). +

Input

```liquid {% raw %} {% for product in collection.products %} @@ -16,6 +17,7 @@ Repeatedly executes a block of code. For a full list of attributes available wit {% endraw %} ``` +

Output

```text hat shirt pants ``` @@ -24,6 +26,7 @@ hat shirt pants Causes the loop to stop iterating when it encounters the `break` tag. +

Input

```liquid {% raw %} {% for i in (1..5) %} @@ -36,6 +39,7 @@ Causes the loop to stop iterating when it encounters the `break` tag. {% endraw %} ``` +

Output

```text 1 2 3 ``` @@ -44,6 +48,7 @@ Causes the loop to stop iterating when it encounters the `break` tag. Causes the loop to skip the current iteration when it encounters the `continue` tag. +

Input

```liquid {% raw %} {% for i in (1..5) %} @@ -56,6 +61,7 @@ Causes the loop to skip the current iteration when it encounters the `continue` {% endraw %} ``` +

Output

```text 1 2 3 5 ``` @@ -66,6 +72,7 @@ Causes the loop to skip the current iteration when it encounters the `continue` Limits the loop to the specified number of iterations. +

Input

```liquid {% raw %} @@ -75,6 +82,7 @@ Limits the loop to the specified number of iterations. {% endraw %} ``` +

Output

```text 1 2 ``` @@ -83,6 +91,7 @@ Limits the loop to the specified number of iterations. Begins the loop at the specified index. +

Input

```liquid {% raw %} @@ -92,6 +101,7 @@ Begins the loop at the specified index. {% endraw %} ``` +

Output

```text 3 4 5 6 ``` @@ -100,6 +110,7 @@ Begins the loop at the specified index. Defines a range of numbers to loop through. The range can be defined by both literal and variable numbers. +

Input

```liquid {% for i in (3..5) %} {{ i }} @@ -113,6 +124,7 @@ Defines a range of numbers to loop through. The range can be defined by both lit {% endraw %} ``` +

Output

```text 3 4 5 1 2 3 4 @@ -122,6 +134,7 @@ Defines a range of numbers to loop through. The range can be defined by both lit Reverses the order of the loop. +

Input

```liquid {% raw %} @@ -131,6 +144,7 @@ Reverses the order of the loop. {% endraw %} ``` +

Output

```text 6 5 4 3 2 1 ``` @@ -141,6 +155,7 @@ Loops through a group of strings and outputs them in the order that they were pa `cycle` must be used within a [for](#for) loop block. +

Input

```liquid {% raw %} {% cycle 'one', 'two', 'three' %} @@ -150,6 +165,7 @@ Loops through a group of strings and outputs them in the order that they were pa {% endraw %} ``` +

Output

```text one two @@ -170,6 +186,7 @@ Uses for `cycle` include: Generates an HTML table. Must be wrapped in opening `` and closing `
` HTML tags. +

Input

```liquid {% raw %} @@ -180,6 +197,7 @@ Generates an HTML table. Must be wrapped in opening `
` and closing `Output

```html
@@ -211,6 +229,7 @@ Generates an HTML table. Must be wrapped in opening `
` and closing `Input

```liquid {% raw %} {% tablerow product in collection.products cols:2 %} @@ -219,6 +238,7 @@ Defines how many columns the tables should have. {% endraw %} ``` +

Output

```html
diff --git a/tags/variable.md b/tags/variable.md index 618e02b..920bdd0 100644 --- a/tags/variable.md +++ b/tags/variable.md @@ -8,6 +8,7 @@ Variable tags create new Liquid variables. Creates a new variable. +

Input

```liquid {% raw %} {% assign my_variable = false %} @@ -17,12 +18,14 @@ Creates a new variable. {% endraw %} ``` +

Output

```text This statement is valid. ``` Wrap a variable in quotations `"` to save it as a string. +

Input

```liquid {% raw %} {% assign foo = "bar" %} @@ -30,6 +33,7 @@ Wrap a variable in quotations `"` to save it as a string. {% endraw %} ``` +

Output

```text bar ``` @@ -38,6 +42,7 @@ bar Captures the string inside of the opening and closing tags and assigns it to a variable. Variables created through `{% raw %}{% capture %}{% endraw %}` are strings. +

Input

```liquid {% raw %} {% capture my_variable %}I am being captured.{% endcapture %} @@ -45,6 +50,7 @@ Captures the string inside of the opening and closing tags and assigns it to a v {% endraw %} ``` +

Output

```text I am being captured. ``` @@ -53,6 +59,7 @@ I am being captured. Creates a new number variable, and increases its value by one every time it is called. The initial value is 0. +

Input

```liquid {% raw %} {% increment my_counter %} @@ -61,6 +68,7 @@ Creates a new number variable, and increases its value by one every time it is c {% endraw %} ``` +

Output

```text 0 1 @@ -71,6 +79,7 @@ Variables created through the `increment` tag are independent from variables cre 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`. +

Input

```liquid {% raw %} {% assign var = 10 %} @@ -81,6 +90,7 @@ In the example below, a variable named "var" is created through `assign`. The `i {% endraw %} ``` +

Output

```text 0 1 @@ -92,6 +102,7 @@ In the example below, a variable named "var" is created through `assign`. The `i Creates a new number variable, and decreases its value by one every time it is called. The initial value is -1. +

Input

```liquid {% raw %} {% decrement variable %} @@ -100,6 +111,7 @@ Creates a new number variable, and decreases its value by one every time it is c {% endraw %} ``` +

Output

```text -1 -2