I’m studying the documentation and trying to learn Grav and Twig. Please bear with me, there are some things I’m not able to figure out on my own. One thing I’m having difficulty with is that I come from a language where all variables or objects must be declared and defined before they are used. Twig, obviously, isn’t that way. Take this code fragment for instance – code sample borrowed from the documentation:
{% for image in page.media.images %}
<li>
<div class="image-surround">
{{ image.cropResize(300,200).html|raw }}
</div>
<div class="image-info">
<h2>{{ image.meta.title }}</h2>
<p>{{ image.meta.description }}</p>
</div>
</li>
{% endfor %}
“page.media.images” is a collection of images in all of a given group of pages, right? “image” is an object created just by using it. Then in each iteration the object is reused and set with the next set of data. and output. That seems straightforward enough…
But there are other objects that are not so obvious where it’s getting the data from and how it knows where to go to get the data. Here’s an example that is not so difficult to figure out:
In some config file…
dropdown:
- enabled: true
(but where is the file and how does Twig know where to find it?)
then you reference it in a twig file:
{% if config.plugins.dropdown.enabled %}
.....
{% endif %}
So the word “dropdown” is declared in the config file, right? Otherwise it would throw and error on the line with the “if” statement. In otherwords, “dropdown” never existed before it was typed into the .yaml config file, right?
But in the case of “page.media.images” these are reserved words of Grav, right?
I have to guess a lot of these things by studying the code, since I have no way to test my theories. There are a lot of other words that are hard to figure out where they come from, why they exist and what they do. Is there a list of reserved words in Grav and what they do and/or where they come from?