Usually I am able to navigate Moodle's codebase fine. For example, if I wanted to see the stacktrace and all the files associated with a line of code I can just add debugging('hello') and I see the full stracktrace.
But working with templates I am currently dumfounded on how to track down where in the code the template is being called from.
For example, I want to see where the template flat_navigation.mustache is being rendered from. I see that it is called from nav-drawer.mustache and that file is called from columns2.mustache and that is called from columns2.php. But how is the flat_navigation template getting its data for flatnavigation? Is it the $OUTPUT object? How?
Is there a stacktrace call for templates?
What is the best approach to finding where templates are being used and where/how is this particular template being generated? I am using Moodle 3.4.