> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kiwify.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional tags

> Conditional tags allow you to control the flow of your templates.

Conditional tags let you execute code only if a certain condition is met. This allows for creating dynamic templates that respond to different states and data.

## `if`

Executes a block of code only if a condition is true.

```liquid theme={null}
{% if condition %}
  // code to execute if condition is true
{% endif %}
```

<ParamField path="condition" type="boolean">
  The condition to evaluate.
</ParamField>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {% if user.is_logged_in %}
      Welcome back, {{ user.name }}!
    {% endif %}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    Welcome back, John!
    ```
  </CodeGroup>
</Columns>

## `else`

Provides an alternative block of code to execute when an `if` condition is false.

```liquid theme={null}
{% if condition %}
  // code to execute if condition is true
{% else %}
  // code to execute if condition is false
{% endif %}
```

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {% if user.is_logged_in %}
      Welcome back, {{ user.name }}!
    {% else %}
      Please log in.
    {% endif %}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    Please log in.
    ```
  </CodeGroup>
</Columns>

## `unless`

The opposite of `if`. Executes a block of code only if a condition is false.

```liquid theme={null}
{% unless condition %}
  // code to execute if condition is false
{% endunless %}
```

<ParamField path="condition" type="boolean">
  The condition to evaluate.
</ParamField>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {% unless user.is_logged_in %}
      Please log in to continue.
    {% endunless %}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    Please log in to continue.
    ```
  </CodeGroup>
</Columns>

## `case`

Executes one of many blocks of code, depending on the value of a variable.

```liquid theme={null}
{% case variable %}
  {% when value1 %}
    // code to execute if variable equals value1
  {% when value2 %}
    // code to execute if variable equals value2
  {% else %}
    // code to execute if variable doesn't match any values
{% endcase %}
```

<ParamField path="variable" type="any">
  The variable to evaluate.
</ParamField>

<Columns cols={2}>
  <CodeGroup>
    ```liquid Code theme={null}
    {% assign level = "advanced" %}

    {% case level %}
      {% when "beginner" %}
        Start with the basics
      {% when "intermediate" %}
        Build on your knowledge
      {% when "advanced" %}
        Tackle complex concepts
      {% else %}
        Select a level
    {% endcase %}
    ```
  </CodeGroup>

  <CodeGroup>
    ```liquid Output theme={null}
    Tackle complex concepts
    ```
  </CodeGroup>
</Columns>
