Debugging Templates

There are times when you are working in a content layout that you need some more information about the variables available on the page. There are a few ways to do that.

Debug one variable

You can use the debug filter or the dump function to debug one variable.

{{ variable|debug }}

or

{{ dump(variable) }}

You can set a label for the debug output by passing a parameter to the debug filter.

{{ variable|debug('Debug Label Here') }}

Debugging for emails

If you are debugging email templates (like the form notification email) then you should use the debug_email filter. It will format the debug output so that it is usable in emails.

{{ form.fields|debug_email('Fields') }}

Debug multiple variables at once

You can pass multiple variables to the dump function and each one will be debugged.

{{ dump(variable, variable2, variable3) }}

Output all variables

If no parameters are passed to the dump function, then the system will output all variables available to the template.

{{ dump() }}