Assumption . From what I understand, Liquid works in such a way that the variable page.my_keycan be compared with a PHP array with the name pageand the key my_key: $page['my_key']. Following the same logic, we can compare {{ page.my_key }}with echo $page['my_key'].
And we could compare this front:
my_key: my_value
to this PHP code:
$page['my_key'] = "my_value";
Question . I would like to do something like this:
$page['my_key'] = "my_value";
$page['my_key2'] = "my_value2";
$key = "my_key";
echo $page[$key];
All I can think of is:
my_key: my_value
my_key2: my_value2
{% assign key = 'my_key' %}
{{ page.{{ key }} }}
However, this does not work ... Is something like that possible?
source
share