Reputation: 103
I need to create a array with a dynamic key.
Example:
{% set key = 'a' %} {% set value = 'b' %} {% set array = {key:value} %}
Upvotes: 10
Views: 7551
Reputation: 39460
I find a workaround for this problem: if you surround the key with parenthesis the key of array take the value of the variable instead of the name. So try simple this:
key
{% set array = { (key): value} %}
Here a working solutions
Upvotes: 24