Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
84266d9
Remove ignored Gemfile.lock
EricFromCanada Jan 25, 2021
78dc366
Condense and improve examples
EricFromCanada Feb 22, 2021
17bc147
Update URLs
EricFromCanada Feb 22, 2021
bcac0b2
Show version badge on recently-added tags
EricFromCanada Feb 22, 2021
1411133
Filters can be used during variable assignment
EricFromCanada Feb 22, 2021
d29ff53
Numbers and array indices can be negative
EricFromCanada Feb 22, 2021
c9b52b9
{% when %} can have multiple cases
EricFromCanada Feb 22, 2021
33767f5
`slice` can be used with arrays
EricFromCanada Feb 22, 2021
b6570a0
{% ifchanged %} is available in `for` loops
EricFromCanada Feb 22, 2021
634c965
Ranges can be assigned to variables
EricFromCanada Feb 22, 2021
299918f
`capitalize` also downcases each remaining letter
EricFromCanada Feb 22, 2021
3d5e966
`offset` can have a `continue` value in `for` loops
EricFromCanada Feb 22, 2021
5015ff6
`default` now has an `allow_false` parameter
EricFromCanada Feb 22, 2021
bc0b2ba
Mention usage of `empty` and EmptyDrop
EricFromCanada Feb 22, 2021
39829ec
Fix wrong space characters & hard returns
EricFromCanada Feb 22, 2021
271f7ca
Improve wording & formatting
EricFromCanada Feb 22, 2021
c1c5770
Add new Template page for comment, raw, liquid, echo, render, include
EricFromCanada Feb 22, 2021
3270930
Remove input whitespace; Explain liquid tag for whitespace control
ADTC Mar 27, 2021
86463e3
Remove input whitespace and make several improvements in the Filters …
ADTC Mar 27, 2021
d280238
Remove input whitespace; Add note about invalid syntax of liquid tag
ADTC Mar 27, 2021
fc10dfb
Add category for filters and display them by category in the sidebar
ADTC Mar 28, 2021
07a9620
Change category for escape/_once (other) and split (array)
ADTC Mar 28, 2021
44c4115
Fix scrollbar and scrolling active link into view on the sidebar
ADTC Mar 28, 2021
22c8bcb
Make the menu button sticky on mobile view
ADTC Mar 28, 2021
3a02cfc
Fix the code block in EmptyDrop section in Types
ADTC Mar 28, 2021
e5f8134
Change the style of filter subheadings to indicate them as such
ADTC Mar 29, 2021
35b9743
Add Template tag type and all filter types in the Introduction page
ADTC Mar 29, 2021
866a664
Double the padding at the bottom of the sidebar menu
ADTC Mar 30, 2021
11a84c0
Add the note about optional "as" in the "render for" section
ADTC Mar 30, 2021
1bd73b9
Add a "deprecated" badge on the "include" Template tag
ADTC Mar 30, 2021
8137ef8
Fix the anchor links in Introduction and Template
ADTC Mar 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 0 additions & 265 deletions Gemfile.lock

This file was deleted.

42 changes: 25 additions & 17 deletions _basics/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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**](#intro-objects), [**tags**](#intro-tags), and [**filters**](#intro-filters) inside **template files** to display dynamic content.

## Objects
<h2 id="intro-objects">Objects</h2>

**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 %}`.

<p class="code-label">Input</p>
```liquid
{% raw %}
{%- raw -%}
{{ page.title }}
{% endraw %}
```
Expand All @@ -22,17 +22,15 @@ 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
<h2 id="intro-tags">Tags</h2>

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

<p class="code-label">Input</p>
```liquid
{% raw %}
{%- raw -%}
{% if user %}
Hello {{ user.name }}!
{% endif %}
Expand All @@ -44,21 +42,22 @@ 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 }})
- [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.

## Filters
<h2 id="intro-filters">Filters</h2>

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

<p class="code-label">Input</p>
```liquid
{% raw %}
{%- raw -%}
{{ "/my/fancy/url" | append: ".html" }}
{% endraw %}
```
Expand All @@ -68,11 +67,11 @@ 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.

<p class="code-label">Input</p>
```liquid
{% raw %}
{%- raw -%}
{{ "adam!" | capitalize | prepend: "Hello " }}
{% endraw %}
```
Expand All @@ -81,3 +80,12 @@ Multiple filters can be used on one output. They are applied from left to right.
```text
{{ "adam!" | capitalize | prepend: "Hello " }}
```

Filters can be categorized into various types:

- <a href="#" onclick="scrollToFilter(event, 'array-filters')">Array filters</a>
- <a href="#" onclick="scrollToFilter(event, 'math-filters')">Math filters</a>
- <a href="#" onclick="scrollToFilter(event, 'string-filters')">String filters</a>
- <a href="#" onclick="scrollToFilter(event, 'filters')">Other filters</a>

You can see the list of filters for each type in their respective sections on the side menu.
Loading