Skip to content

Instantly share code, notes, and snippets.

@bartwttewaall
Created January 30, 2024 10:47
Show Gist options
  • Save bartwttewaall/d8bcfb2c9dc64a31ec0fe05edb9d235f to your computer and use it in GitHub Desktop.
Save bartwttewaall/d8bcfb2c9dc64a31ec0fe05edb9d235f to your computer and use it in GitHub Desktop.
Debugging twig templates
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