Score:0

Disable theme debugging html comments in particular view?

in flag

we are running commerce site, still tweaking some bits, so we have still twig debug set to true, but site is already online.. we have XML feed for exporting commerce products to couple of price comparison sites.. and XML feed is of course marked as invalid, because even in XML views feed are html theme suggestion comments, any chance to turn off those for particular view?

Thank you.

<SHOP xmlns="http://www.zbozi.cz/ns/offer/1.0">
    

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'xmlfeedviews_row' -->
<!-- BEGIN OUTPUT from 'modules/contrib/xmlfeedviews/templates/xmlfeedviews-row.html.twig' -->
<SHOPITEM>
    <PRODUCTNAME>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->
Náhradní filtry k ionizátorům H2
<!-- END OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->

</PRODUCTNAME>
<DESCRIPTION>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->
Životnost filtrů je 1000 galonů (3800 litrů). Vyměnit filtry k ionizátoru není složité a zvládnete to sami.

<!-- END OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->

</DESCRIPTION>
<URL>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->
https://www.fitvoda.cz/nahradni-filtry-k-ionizatorum-h2
<!-- END OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->

</URL>
<PRICE_VAT>

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->
4990.00
<!-- END OUTPUT from 'core/modules/views/templates/views-view-field.html.twig' -->

</PRICE_VAT>
... etc
sonfd avatar
in flag
Don't enable twig debugging on live sites.
Score:1
cn flag

No, I don't think you can turn off twig debugging for only some parts of the site. It's either on or it's off.

Anyway, you are risking a lot of trouble making changes to a live site. It's much better to set up a local development environment and make your code changes locally. One cross-platform tool for this is Lando but there are many others as well. Drupal.org has a full guide on local server setups.

Also, the documentation specifically states that Twig debugging can break parts of the site, including views. See this issue.

Zdeněk Nováček avatar
in flag
Thanks a lot guys.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.