-
Notifications
You must be signed in to change notification settings - Fork 34
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 dump error? #30
Comments
Dumping is not possible natively in twig. |
I tried this but sadly I still have the issue. |
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! :)
The text was updated successfully, but these errors were encountered: