twig debug undesired behavior ?


I experience an undesired behavior when enabled twig debug. It took me a while to find out why and believe, if I’m correct, it may deserve a fix or related solution.

I created a block view with a global custom text into it. It is build with replacement tokens and with a basic twig code it returns an empty string in some cases. This works fine.

For this field I create a linked label to display what we’re talking of and also requested to have label and field text hidden if twig return is empty. This works fine too.

However, when twig debug is enabled from services.yml. It verbose twig processing output in the DIV (as per expected). This being said, even if twig returns empty string, div is not considered as empty and label displayed where it there is no reason.

I can live with that as twig debug is temporary, nevertheless processing is misleading.

Drupal version: