Open csikoszoltan opened 2 years ago
Dumping is not possible natively in twig. I personally use this: https://github.com/djboris88/timber-debugger
Dumping is not possible natively in twig. I personally use this: https://github.com/djboris88/timber-debugger
I tried this but sadly I still have the issue. Weird because I'm using Timber (without Lumberjack) and its working there...
It works well for me,
Try to use this ServiceProvider :
<?php
namespace App\Providers;
use Ajgl\Twig\Extension\BreakpointExtension;
use Rareloop\Lumberjack\Config;
use Djboris88\Twig\Extension\CommentedIncludeExtension;
use HelloNico\Twig\DumpExtension;
class TimberDebuggerServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*/
public function boot(Config $config)
{
if (defined('WP_DEBUG') && WP_DEBUG && function_exists('add_filter')) {
add_filter('timber/loader/twig', function ($twig) {
$twig->addExtension(new CommentedIncludeExtension());
$twig->addExtension(new DumpExtension());
$twig->addExtension(new BreakpointExtension());
return $twig;
});
/*
* Adding a second filter to cover the `Timber::render()` case, when the
* template is not loaded through the `include` tag inside a twig file
*/
add_filter(
'timber/output',
function ($output, $data, $file) {
return "\n<!-- Begin output of '" . $file . "' -->\n" . $output . "\n<!-- / End output of '" . $file . "' -->\n";
},
10,
3,
);
}
}
}
It works now! Thanks for your help! :)
What are the steps to reproduce this issue?
Use dump() in any .twig file.
What happens?
The dumped data is not formatted in a colorful way like if you dump it in a php file.
What versions of software are you using?
Operating System: MacOS 12.3.1.
PHP Version: 8.0
Lumberjack Version: 5.0.0
It should be like this:
Thanks! :)