> For the complete documentation index, see [llms.txt](https://cryptococo.gitbook.io/cocoshop-theme-development/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cryptococo.gitbook.io/cocoshop-theme-development/liquid/tags/variable.md).

# Variable

Variable tags are used to create and manipulate variables in Liquid. They allow you to store data and perform operations on variables that can be used throughout your template. The following tags are available for working with variables: `assign`, `capture`, `decrement`, and `increment`.

## assign

The `assign` tag is used to create a new variable or update the value of an existing variable. The syntax for the `assign` tag is:

```liquid
{% assign variable_name = value %}
```

Example: Assigning a variable named `discount` with a value of 10

```liquid
{% assign discount = 10 %}
```

You can also use expressions or other variables when assigning a value:

```liquid
{% assign discounted_price = product.price * (1 - discount / 100) %}
```

## Capture

The `capture` tag is used to store the output of a block of Liquid code in a variable. The syntax for the `capture` tag is:

```liquid
{% capture variable_name %}
  Liquid code to be captured
{% endcapture %}
```

Example: Capturing the output of a loop in a variable named `product_list`

```liquid
{% capture product_list %}
  <ul>
    {% for product in products %}
      <li>{{ product.title }}</li>
    {% endfor %}
  </ul>
{% endcapture %}
```

You can then use the `product_list` variable elsewhere in your template:

```liquid
<div class="product-list">
  {{ product_list }}
</div>
```

## Decrement

The `decrement` tag is used to decrease the value of a variable by 1. If the variable doesn't exist, it will be created and set to -1. The syntax for the `decrement` tag is:

```liquid
{% decrement variable_name %}
```

Example: Decrementing a variable named `counter`

```liquid
{% decrement counter %}
```

## Increment

The `increment` tag is used to increase the value of a variable by 1. If the variable doesn't exist, it will be created and set to 1. The syntax for the `increment` tag is:

```liquid
{% increment variable_name %}
```

Example: Incrementing a variable named `counter`

```liquid
{% increment counter %}
```

By using these variable tags, you can create, manipulate, and store data in your Liquid templates, making it easier to perform calculations, create reusable content, and manage the state of your application.<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cryptococo.gitbook.io/cocoshop-theme-development/liquid/tags/variable.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
