Variables are of a given type and store data of that type. Each variable need to have an unique name, which is used for accessing them. For example you could use a variable with the name 'height' and store the value '2.3' (a float) in it. Afterwards you can access the variable by its name, the variable acts as a kind of placeholder for its value.

In order to access such objects and types, they need to be defined first, the FlickRocket shop system will provide a large number of pre-defined variables (the set of variables will always be the same for the same type of page – e.g. a product page will contain variables specific for the chosen product, which couldn't be defined on the index page). The list of pre-defined variables will follow later on.

Of course it is also possible to define variables for yourself, this could be quite helpful in order to do some basic calculations or to pass information pre-processed to a different part of the page. In order to use a variable, it must be defined first, think of it as b = 5. This is called assignment and afterwards the variable b will contain the value 5. If you assign another value to b later in the page, the original value of b will be overwritten. This can be used for example as a counter like b = b + 1, where b will be overwritten with the old value of b plus 1. There is only one exception from this, which is explained in the next chapter.


A scope is a part of a program (or in this case of a template), where a variable is valid and can be accessed. Usually a variable is valid in the whole HTML template (from the point on where it is defined), unless it is defined within a block. In that case, the variable is only valid within that block. Imagine the following structure:

{% assign b = 5 %}
{% for collection in collections %}
  {% comment %} In the first iteration, b has still the value 5 {% endcomment %}
  {% assign b = 3 %}
{% endfor %}

Let's see what happens here: At first, b is assigned the value 5. Then a loop over all collections is performed (the loop ends with the tag endfor). Within the loop (or within each part of an if clause) a new block is defined. At the beginning of the loop, b is still defined from outside of the block and still contains 5 (from outside of the loop), but as soon the second assignment occurs, the new value of b will be 3. After the loop has ended, the value of b will be restored to 5! This is because the scope of the assignment within the loop is only the loop itself.

Of course a loop can contain another loop, which then will again define a new block (which is contained in the outer loop block).


Read more 

More about Liquid placeholders

More about object types