Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make twig's dump function to display the data unfolded?

I'm using the dump function of the twig.

But it shows the data "folded", like in here:

Twig Dump Folded

When I click the arrow, I may reveal the data by unfolding it, like in here:

Twig Dump Unfolded

Question:

Is there any way to tell the twig or dump to directly display the objects fully-unfolded.

like image 583
Xavi Montero Avatar asked Feb 06 '23 10:02

Xavi Montero


1 Answers

You can do this with javascript (jQuery):

    // Expand all dump levels of all sf-dumps on a page.
    $("pre.sf-dump").each(function() {
        $(this).find("a.sf-dump-toggle:gt(0)").each(function(i, a){
            a.click();
        });
    })

This simulates the user clicking each dump toggle (excluding the first one with gt(0)) of each sf-dump on a page.

Edit: I added an each() function to make the script work for any number of sf-dumps there might be on a page. Thanks to @Xavi

like image 80
Graftak Avatar answered Feb 08 '23 15:02

Graftak