Created
January 30, 2024 10:47
-
-
Save bartwttewaall/d8bcfb2c9dc64a31ec0fe05edb9d235f to your computer and use it in GitHub Desktop.
Debugging twig templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some usefull tips to debug in templates: | |
```twig | |
{{ dump(_context) }} | |
{{ dump(_context|keys) }} | |
{{ dump(myProductQuery.rawSQL()) }} | |
``` | |
If you ever lose the overview of what template is used at what url, you can use this snippet in each template to show the template name as a regular html comment. | |
```twig | |
{% if craft.app.config.general.devMode %} | |
<!-- Template: {{ _self }} --> | |
{% endif %} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment