Here is a quick alternative to see which variables are available in a twig template when you don't have a debugger like xdebug.
It is especially useful when you want to verify that certain values are available to be printed in a particular template.
Simply put this snippet in the twig file you want to scan and it will print a list of the available variables (they will be printed in the position where you put the snippet):
<ol>
{% for key, value in _context %}
<li>{{ key }}</li>
{% endfor %}
</ol>
Result:
Bye!
Add new comment