CASE: dynamic variable names

To explain why we use dynamic variable names in this case:

Let’s say we create a variable called :

{% assign var_xyz = "100" %}

We also create this:

{% assign i = "xyz" %}
{% capture variable %}var_{{ i }}{% endcapture %} 

So the output of {{ variable }} is simply the name we capture :

var_xyz

However, if we want to access the value of the variable var_xyz, we need to use this:

{{ [variable] }} 

which outputs this:

100

So the name of the variable var_xyz gets created by the capture-code, and we display that value with .

A case where this is used, can be found here:

Complete code use case:

{% assign var_xyz = "100" %}
{% assign i = "xyz" %}
{% capture variable %}var_{{ i }}{% endcapture %}

{% comment %}Output of the capture code{% endcomment %}  
{{ variable }}

{% comment %}Output of the variable assign code{% endcomment %} 
{{ [variable] }}