What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

where can i activate Twig debug mode for yves? I tried to add debug => true to \Spryker\Shared\Tw

U01BZ7Q3XRV
U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

where can i activate Twig debug mode for yves? I tried to add debug => true to \Spryker\Shared\Twig\TwigConstants::YVES_TWIG_OPTIONS, but it does not work.

Comments

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    it seems that the getTwigOptions function is not even called during an yves page load \Spryker\Yves\Twig\TwigConfig::getTwigOptions

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok still it seems to be the right place, at least \Twig\Environment::__construct is called with debug: true

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    but I would expect now html comments with template paths to be rendered, which is not the case

  • U016M00EGD6
    U016M00EGD6 Posts: 1 πŸ§‘πŸ»β€πŸš€ - Cadet

    it should be sufficient to add it to your config_local.php

    $config[TwigConstants::YVES_TWIG_OPTIONS] = [
        'debug' => true,
    ];
    

    maybe you also need to enable debugging (not sure if it is needed for twig)

    $config[ApplicationConstants::ENABLE_APPLICATION_DEBUG] = true;
    
  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    thanks, but unfortunately it does not work. Not sure why. Currently I try to find the place where Twig would dump the information

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    How old is the project?

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    We had an issue in configs a while ago and this was the PR to fix it for spryker/docker-sdk based env.

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited March 2022

    @valerii.trots it should be the B2B Demo from last August

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    I'll try to check now.

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    Works.

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    I did not test the dump to be honest. I mean that twig outputs a html comment with each template rendered with template path (and possibly some other context). Just now I think maybe its not a twig feature, but implemented e.g. in drupal here as an extension: https://www.drupal.org/docs/theming-drupal/twig-in-drupal/locating-template-files-with-debugging

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    In Magento there even was (is?) a chrome plugin with a dev tools extension that provides a clickable link in the inspector tab which opens the correct template in phpstorm for editing (but a html commecnt with the path would be more then enough for the start πŸ˜› ).

  • U01BZ7Q3XRV
    U01BZ7Q3XRV Posts: 148 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok, I have no idea how drupal works, but actually this code here looks like they implemented it and its not part of twig actually. But that's ok, then we can build the same thing probably in Sprykerhttps://github.com/drupal/drupal/blob/6e5fd14d91e8f5f2bf892748803871470ea8e925/core/themes/engines/twig/twig.engine#L60