Coder Social home page Coder Social logo

Twig dump error? about lumberjack HOT 4 OPEN

rareloop avatar rareloop commented on May 23, 2024
Twig dump error?

from lumberjack.

Comments (4)

csikoszoltan avatar csikoszoltan commented on May 23, 2024 1

It works now! Thanks for your help! :)

from lumberjack.

Androlax2 avatar Androlax2 commented on May 23, 2024

Dumping is not possible natively in twig.
I personally use this: https://github.com/djboris88/timber-debugger

from lumberjack.

csikoszoltan avatar csikoszoltan commented on May 23, 2024

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...

from lumberjack.

Androlax2 avatar Androlax2 commented on May 23, 2024

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,
            );
        }
    }
}

from lumberjack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.