0

Is it possible to disable theme debug in one field? I don't want to disable theme debug, but when I set up background file from field, theme debug comments block this style functionality.

2 Answers 2

2

No, this is not possible.

You would need to hack core in order to do it (twig_render_template), which might be ok for your local development.

The code in interest is this part:

if ($twig_service->isDebug()) {
  $output['debug_prefix'] .= "\n\n<!-- THEME DEBUG -->";
  ...
}

You could add a condition, like this:

 if ($twig_service->isDebug() && $template_file != 'awesome-template-file') {

I'm not sure what $template_file looks like, but I'm sure you could use it to make a condition to make the template file in question be skipped debug. This actually requires that the field uses it's own template file though.

0

Late to the party, but you can do the following:

      $twig_service = \Drupal::service('twig');
      $was_debugging = FALSE;
      if ($twig_service->isDebug()) {
        $was_debugging = TRUE;
        $twig_service->disableDebug();
      }

...
Do your thing.
...


      if ($was_debugging) {
        $twig_service->enableDebug();
      }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.