Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig variable dump improvements #12486

Merged
merged 2 commits into from
Dec 24, 2022
Merged

Twig variable dump improvements #12486

merged 2 commits into from
Dec 24, 2022

Conversation

brandonkelly
Copy link
Member

@brandonkelly brandonkelly commented Dec 24, 2022

Description

Adds a new dump() function, which outputs a variable(s) via Craft::dump(). It replaces the dump() function provided by Twig’s Debug extension, and doesn’t require Dev Mode to be active. To maintain consistency with the original, the new one supports outputting multiple variables at once by passing them as separate arguments, and will default to outputting the entire context array if no arguments are provided.

{{ dump(foo, bar, baz) }}
{{ dump() }} → context array

The {% dd %} tag has also been updated to no longer require a variable, in which case the entire context array will be output.

{% dd foo %}
{% dd %} → context array

Passing multiple values to {% dd %} is not supported, as the application will exit before we could loop around to the second. If you want to do that, you’d have to pass them as a hash:

{% dd {foo: foo, bar: bar} %}

Related issues

@brandonkelly brandonkelly requested a review from a team as a code owner December 24, 2022 15:50
[ci skip]
@brandonkelly brandonkelly merged commit 83b15db into 4.4 Dec 24, 2022
@brandonkelly brandonkelly deleted the feature/dump-improvements branch December 24, 2022 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant