Assumption - From what I understand, Liquid works in a way that the variable page.my_key
can be compared to a PHP array with name page
and key my_key
: $page['my_key']
. Following this same logic we could compare {{ page.my_key }}
with echo $page['my_key']
.
And we could compare this front matter:
----
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, that does not work... Is something like this possible, though?