diff --git a/_basics/introduction.md b/_basics/introduction.md index 167a685..285363d 100644 --- a/_basics/introduction.md +++ b/_basics/introduction.md @@ -19,7 +19,7 @@ Liquid code can be categorized into [**objects**](#objects), [**tags**](#tags),

Output

```text -Introduction +{{ page.title }} ``` In this case, Liquid is rendering the content of an object called `page.title`, and that object contains the text `Introduction`. @@ -79,5 +79,5 @@ Multiple filters can be used on one output. They are applied from left to right.

Output

```text -Hello Adam! +{{ "adam!" | capitalize | prepend: "Hello " }} ``` diff --git a/_filters/abs.md b/_filters/abs.md index e7dcedf..e244fd1 100644 --- a/_filters/abs.md +++ b/_filters/abs.md @@ -15,7 +15,7 @@ Returns the absolute value of a number.

Output

```text -17 +{{ -17 | abs }} ```

Input

@@ -27,7 +27,7 @@ Returns the absolute value of a number.

Output

```text -4 +{{ 4 | abs }} ``` `abs` will also work on a string if the string only contains a number. @@ -41,5 +41,5 @@ Returns the absolute value of a number.

Output

```text -19.86 +{{ "-19.86" | abs }} ``` diff --git a/_filters/at_least.md b/_filters/at_least.md index d7a43cd..985ad48 100644 --- a/_filters/at_least.md +++ b/_filters/at_least.md @@ -13,7 +13,7 @@ Limits a number to a minimum value. ```

Output

-``` +```text 5 ``` @@ -25,6 +25,6 @@ Limits a number to a minimum value. ```

Output

-``` +```text 4 ``` diff --git a/_filters/at_most.md b/_filters/at_most.md index e05a7b4..68d5f8f 100644 --- a/_filters/at_most.md +++ b/_filters/at_most.md @@ -13,7 +13,7 @@ Limits a number to a maximum value. ```

Output

-``` +```text 4 ``` @@ -25,6 +25,6 @@ Limits a number to a maximum value. ```

Output

-``` +```text 3 ``` diff --git a/_filters/capitalize.md b/_filters/capitalize.md index 1b160e4..0631aff 100644 --- a/_filters/capitalize.md +++ b/_filters/capitalize.md @@ -14,7 +14,7 @@ Makes the first character of a string capitalized.

Output

```text -Title +{{ "title" | capitalize }} ``` `capitalize` only capitalizes the first character of the string, so later words are not affected: @@ -28,5 +28,5 @@ Title

Output

```text -My great title +{{ "my great title" | capitalize }} ``` diff --git a/_filters/compact.md b/_filters/compact.md index 1627318..66333be 100644 --- a/_filters/compact.md +++ b/_filters/compact.md @@ -13,20 +13,20 @@ For this example, assume `site.pages` is an array of content pages for a website {% assign site_categories = site.pages | map: 'category' %} {% for category in site_categories %} - {{ category }} +- {{ category }} {% endfor %} {% endraw %} ```

Output

```text - business - celebrities - - lifestyle - sports - - technology +- business +- celebrities +- +- lifestyle +- sports +- +- technology ``` By using `compact` when we create our `site_categories` array, we can remove all the `nil` values in the array. @@ -37,16 +37,16 @@ By using `compact` when we create our `site_categories` array, we can remove all {% assign site_categories = site.pages | map: 'category' | compact %} {% for category in site_categories %} - {{ category }} +- {{ category }} {% endfor %} {% endraw %} ```

Output

```text - business - celebrities - lifestyle - sports - technology +- business +- celebrities +- lifestyle +- sports +- technology ``` diff --git a/_filters/first.md b/_filters/first.md index a03ca43..450cfc3 100644 --- a/_filters/first.md +++ b/_filters/first.md @@ -8,17 +8,13 @@ Returns the first item of an array.

Input

```liquid {% raw %} -{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} - -{{ my_array.first }} +{{ "Ground control to Major Tom." | split: " " | first }} {% endraw %} ```

Output

```text -{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} - -{{ my_array.first }} +{{ "Ground control to Major Tom." | split: " " | first }} ```

Input

diff --git a/_filters/last.md b/_filters/last.md index 2e99720..50e14f8 100644 --- a/_filters/last.md +++ b/_filters/last.md @@ -8,17 +8,13 @@ Returns the last item of an array.

Input

```liquid {% raw %} -{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} - -{{ my_array.last }} +{{ "Ground control to Major Tom." | split: " " | last }} {% endraw %} ```

Output

```text -{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} - -{{ my_array.last }} +{{ "Ground control to Major Tom." | split: " " | last }} ```

Input

diff --git a/_filters/map.md b/_filters/map.md index 9b352a8..ddeff20 100644 --- a/_filters/map.md +++ b/_filters/map.md @@ -13,16 +13,16 @@ In this example, assume the object `site.pages` contains all the metadata for a {% assign all_categories = site.pages | map: "category" %} {% for item in all_categories %} -{{ item }} +- {{ item }} {% endfor %} {% endraw %} ```

Output

```text -business -celebrities -lifestyle -sports -technology +- business +- celebrities +- lifestyle +- sports +- technology ``` diff --git a/_filters/replace_first.md b/_filters/replace_first.md index d9703e7..c25ee3a 100644 --- a/_filters/replace_first.md +++ b/_filters/replace_first.md @@ -8,13 +8,11 @@ Replaces only the first occurrence of the first argument in a string with the se

Input

```liquid {% raw %} -{% assign my_string = "Take my protein pills and put my helmet on" %} -{{ my_string | replace_first: "my", "your" }} +{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }} {% endraw %} ```

Output

```text -{% assign my_string = "Take my protein pills and put my helmet on" %} -{{ my_string | replace_first: "my", "your" }} +{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }} ``` diff --git a/_filters/size.md b/_filters/size.md index 1716767..83f6667 100644 --- a/_filters/size.md +++ b/_filters/size.md @@ -22,7 +22,7 @@ Returns the number of characters in a string or the number of items in an array. {% raw %} {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} -{{ my_array | size }} +{{ my_array.size }} {% endraw %} ``` @@ -30,7 +30,7 @@ Returns the number of characters in a string or the number of items in an array. ```text {% assign my_array = "apples, oranges, peaches, plums" | split: ", " %} -{{ my_array | size }} +{{ my_array.size }} ``` You can use `size` with dot notation when you need to use the filter inside a tag. diff --git a/_filters/url_decode.md b/_filters/url_decode.md index e6f1991..6cf9087 100644 --- a/_filters/url_decode.md +++ b/_filters/url_decode.md @@ -14,5 +14,5 @@ Decodes a string that has been encoded as a URL or by [`url_encode`]({{ '/filter

Output

```text -'Stop!' said Fred +{{ "%27Stop%21%27+said+Fred" | url_decode }} ``` diff --git a/_tags/iteration.md b/_tags/iteration.md index f87da41..6cb7a4a 100644 --- a/_tags/iteration.md +++ b/_tags/iteration.md @@ -203,6 +203,24 @@ Uses for `cycle` include: `cycle` accepts a parameter called `cycle group` in cases where you need multiple `cycle` blocks in one template. If no name is supplied for the cycle group, then it is assumed that multiple calls with the same parameters are one group. +

Input

+```liquid +{% raw %} +{% cycle "first": "one", "two", "three" %} +{% cycle "second": "one", "two", "three" %} +{% cycle "second": "one", "two", "three" %} +{% cycle "first": "one", "two", "three" %} +{% endraw %} +``` + +

Output

+```text +one +one +two +two +``` + ## tablerow Generates an HTML table. Must be wrapped in opening `` and closing `
` HTML tags.